1 /-
2 Copyright (c) 2018 Chris Hughes. All rights reserved.
3 Released under Apache 2.0 license as described in the file LICENSE.
4 Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne
5 -/
6 import tactic.linarith data.complex.exponential analysis.specific_limits
src └─────────────┘ └──────────────────────┘ └──────────────────────┘
7 group_theory.quotient_group analysis.complex.basic
src └─────────────────────────┘ └────────────────────┘
8
9
10 /-!
11 # Exponential
12
13 ## Main definitions
14
15 This file contains the following definitions:
16 * π, arcsin, arccos, arctan
17 * argument of a complex number
18 * logarithm on real and complex numbers
19 * complex and real power function
20
21 ## Main statements
22
23 The following functions are shown to be continuous:
24 * complex and real exponential function
25 * sin, cos, tan, sinh, cosh
26 * logarithm on real numbers
27 * real power function
28 * square root function
29
30 The following functions are shown to be differentiable, and their derivatives are computed:
31 * complex and real exponential function
32 * sin, cos, sinh, cosh
33
34 ## Tags
35
36 exp, log, sin, cos, tan, arcsin, arccos, arctan, angle, argument, power, square root,
37
38 -/
39 noncomputable theory
40
41 open finset filter metric asymptotics
42 open_locale topological_space
43
44 namespace complex
45
46 /-- The complex exponential is everywhere differentiable, with the derivative `exp x`. -/
47 lemma has_deriv_at_exp (x : ℂ) : has_deriv_at exp (exp x) x :=
id ┴ └──────────┘ └─┘ └─┘ ┴ ┴
src ┴ └──────────┘ └─┘ └─┘
typ ┴ └──────────┘ └─┘ └─┘ ┴ ┴
doc └──────────┘
48 begin
st └─────
49 rw has_deriv_at_iff_is_o_nhds_zero,
id └─────────────────────────────┘
src └─┘└─────────────────────────────┘
typ └─┘└─────────────────────────────┘
doc └─┘
txt └─┘
par └─┘
pid ┴
st ───────────────────────────────────┘└─
50 have : (1 : ℕ) < 2 := by norm_num,
id ┴
src └─────┘ └──┘ └┘┴└────┘ ┴└──────┘
typ └─────┘ └──┘ └┘┴└────┘ ┴└──────┘
doc └─────┘ └──┘ └┘ └────┘ ┴└──────┘
txt └─────┘ └──┘ └┘ └────┘ ┴└──────┘
par └─────┘ └──┘ └┘ └────┘ ┴└──────┘
pid └───┘└┘ └──┘ └┘ ┴└───┘ └───────┘
st ─────────────────────────┘└───────┘└─
51 refine is_O.trans_is_o ⟨∥exp x∥, _⟩ (is_o_pow_id this),
id └─────────────┘ ┴└─┘ ┴┴ └─────────┘ └──┘
src └─────┘└─────────────┘┴ ┴└─┘┴ ┴└───┘ └─────────┘┴ ┴
typ └─────┘└─────────────┘┴ ┴└─┘┴┴┴└───┘ └─────────┘┴└──┘┴
doc └─────┘ ┴ ┴ └───┘ ┴ ┴
txt └─────┘ ┴ ┴ └───┘ ┴ ┴
par └─────┘ ┴ ┴ └───┘ ┴ ┴
pid ┴ ┴ ┴ └───┘ ┴ ┴
st ───────────────────────────────────────────────────────┘└─
52 have : metric.ball (0 : ℂ) 1 ∈ nhds (0 : ℂ) := metric.ball_mem_nhds 0 zero_lt_one,
id └─────────┘ ┴ └──┘ └──────────────────┘ └─────────┘
src └─────┘└─────────┘┴ └──┘ └──┘┴┴└──┘┴ └──┘ └───┘└──────────────────┘└─┘└─────────┘
typ └─────┘└─────────┘┴ └──┘ └──┘┴┴└──┘┴ └──┘ └───┘└──────────────────┘└─┘└─────────┘
doc └─────┘└─────────┘┴ └──┘ └──┘ ┴└──┘┴ └──┘ └───┘ └─┘
txt └─────┘ ┴ └──┘ └──┘ ┴ ┴ └──┘ └───┘ └─┘
par └─────┘ ┴ └──┘ └──┘ ┴ ┴ └──┘ └───┘ └─┘
pid └───┘└┘ ┴ └──┘ └──┘ ┴ ┴ └──┘ ┴└──┘ └─┘
st ──────────────────────────────────────────────────────────────────────────────────┘└─
53 apply filter.mem_sets_of_superset this (λz hz, _),
id └─────────────────────────┘ └──┘
src └────┘└─────────────────────────┘┴ ┴ └──────┘
typ └────┘└─────────────────────────┘┴└──┘┴ └──────┘
doc └────┘ ┴ ┴ └──────┘
txt └────┘ ┴ ┴ └──────┘
par └────┘ ┴ ┴ └──────┘
pid ┴ ┴ ┴ └──────┘
st ──────────────────────────────────────────────────┘└─
54 simp only [metric.mem_ball, dist_zero_right] at hz,
id └─────────────┘ └─────────────┘
src └─────────┘└─────────────┘└┘└─────────────┘└─────┘
typ └─────────┘└─────────────┘└┘└─────────────┘└─────┘
doc └─────────┘ └┘ └─────┘
txt └─────────┘ └┘ └─────┘
par └─────────┘ └┘ └─────┘
pid ┴└──┘└┘ └┘ ┴┴└───┘
st ───────────────────────────────────────────────────┘└─
55 simp only [exp_zero, mul_one, one_mul, add_comm, normed_field.norm_pow,
id └──────┘ └─────┘ └─────┘ └──────┘ └───────────────────┘
src └─────────┘└──────┘└┘└─────┘└┘└─────┘└┘└──────┘└┘└───────────────────┘└─
typ └─────────┘└──────┘└┘└─────┘└┘└─────┘└┘└──────┘└┘└───────────────────┘└─
doc └─────────┘ └┘ └┘ └┘ └┘ └─
txt └─────────┘ └┘ └┘ └┘ └┘ └─
par └─────────┘ └┘ └┘ └┘ └┘ └─
pid ┴└──┘└┘ └┘ └┘ └┘ └┘ └─
st ──────────────────────────────────────────────────────────────────────────
56 zero_add, set.mem_set_of_eq],
id └──────┘ └───────────────┘
src ────────────┘└──────┘└┘└───────────────┘┴
typ ────────────┘└──────┘└┘└───────────────┘┴
doc ────────────┘ └┘ ┴
txt ────────────┘ └┘ ┴
par ────────────┘ └┘ ┴
pid ────────────┘ └┘ ┴
st ────────────────────────────────────────┘└─
57 calc ∥exp (x + z) - exp x - z * exp x∥
id └──┘ ┴ ┴ ┴
src └──┘ ┴ ┴ ┴
typ └──┘ ┴ ┴ ┴
doc └──┘
st ─────────────────────────────────────────
58 = ∥exp x * (exp z - 1 - z)∥ : by { congr, rw [exp_add], ring }
id ┴ └─┘ ┴ └─────┘
src └─┘ └───┘ └──┘└─────┘┴ └───┘
typ ┴ └─┘ ┴ └───┘ └──┘└─────┘┴ └───┘
doc └──┘ ┴ └───┘
txt └───┘ └──┘ ┴ └───┘
par └───┘ └──┘ ┴ └───┘
pid └┘ ┴ ┴
st ───────────────────────────────────┘└──────┘└───────────┘└──────┘└┘
59 ... = ∥exp x∥ * ∥exp z - 1 - z∥ : normed_field.norm_mul _ _
id ┴ └───────────────────┘
src ┴ └───────────────────┘
typ ┴ └───────────────────┘
st └───────────────────────────────────────────────────────────────
60 ... ≤ ∥exp x∥ * ∥z∥^2 :
id ┴
src ┴
typ ┴
st ────────────────────────────
61 mul_le_mul_of_nonneg_left (abs_exp_sub_one_sub_id_le (le_of_lt hz)) (norm_nonneg _)
id └───────────────────────┘ └───────────────────────┘ └──────┘ └┘ └─────────┘
src └───────────────────────┘ └───────────────────────┘ └──────┘ └─────────┘
typ └───────────────────────┘ └───────────────────────┘ └──────┘ └┘ └─────────┘
st ────────────────────────────────────────────────────────────────────────────────────────┘└
62 end
st ──┘
63
64 lemma differentiable_exp : differentiable ℂ exp :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
65 λx, (has_deriv_at_exp x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
doc └──────────────┘
66
67 @[simp] lemma deriv_exp : deriv exp = exp :=
id └───┘ └─┘ ┴ └─┘
src └───┘ └─┘ ┴ └─┘
typ └───┘ └─┘ ┴ └─┘
doc └──┘ └───┘
68 funext $ λ x, (has_deriv_at_exp x).deriv
id └────┘ ┴ └──────────────┘ ┴ └───┘
src └────┘ └──────────────┘ └───┘
typ └────┘ ┴ └──────────────┘ ┴ └───┘
doc └──────────────┘
69
70 @[simp] lemma iter_deriv_exp : ∀ n : ℕ, (deriv^[n] exp) = exp
id ┴ ┴ └───┘└┘┴┴ └─┘ ┴ └─┘
src ┴ └───┘└┘ ┴ └─┘ ┴ └─┘
typ ┴ ┴ └───┘└┘┴┴ └─┘ ┴ └─┘
doc └──┘ └───┘
71 | 0 := rfl
id └─┘
src └─┘
typ └─┘
72 | (n+1) := by rw [nat.iterate_succ, deriv_exp, iter_deriv_exp n]
id ┴ └──────────────┘ └───────┘ └────────────┘ ┴
src ┴ └──┘└──────────────┘└┘└───────┘└┘ ┴ └─
typ ┴ └──┘└──────────────┘└┘└───────┘└┘└────────────┘┴┴└─
doc └──┘ └┘ └┘ ┴ └─
txt └──┘ └┘ └┘ ┴ └─
par └──┘ └┘ └┘ ┴ └─
pid └┘ └┘ └┘ ┴ ┴└
st └───────────────────┘└─────────┘└────────────────┘┴└
73
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
74 lemma continuous_exp : continuous exp :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
75 differentiable_exp.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
76
77 end complex
78
79 lemma has_deriv_at.cexp {f : ℂ → ℂ} {f' x : ℂ} (hf : has_deriv_at f f' x) :
id ┴ ┴ ┴ └──────────┘ ┴ └┘ ┴
src ┴ ┴ ┴ └──────────┘
typ ┴ ┴ ┴ └──────────┘ ┴ └┘ ┴
doc └──────────┘
80 has_deriv_at (complex.exp ∘ f) (f' * complex.exp (f x)) x :=
id └──────────┘ └─────────┘ ┴ ┴ └┘ ┴ └─────────┘ ┴ ┴ ┴
src └──────────┘ └─────────┘ ┴ ┴ └─────────┘
typ └──────────┘ └─────────┘ ┴ ┴ └┘ ┴ └─────────┘ ┴ ┴ ┴
doc └──────────┘
81 (complex.has_deriv_at_exp (f x)).comp x hf
id └──────────────────────┘ ┴ ┴ └──┘ ┴ └┘
src └──────────────────────┘ └──┘
typ └──────────────────────┘ ┴ ┴ └──┘ ┴ └┘
doc └──────────────────────┘ └──┘
82
83 lemma has_deriv_within_at.cexp {f : ℂ → ℂ} {f' x : ℂ} {s : set ℂ}
id ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ └─┘ ┴
84 (hf : has_deriv_within_at f f' s x) :
id └─────────────────┘ ┴ └┘ ┴ ┴
src └─────────────────┘
typ └─────────────────┘ ┴ └┘ ┴ ┴
doc └─────────────────┘
85 has_deriv_within_at (complex.exp ∘ f) (f' * complex.exp (f x)) s x :=
id └─────────────────┘ └─────────┘ ┴ ┴ └┘ ┴ └─────────┘ ┴ ┴ ┴ ┴
src └─────────────────┘ └─────────┘ ┴ ┴ └─────────┘
typ └─────────────────┘ └─────────┘ ┴ ┴ └┘ ┴ └─────────┘ ┴ ┴ ┴ ┴
doc └─────────────────┘
86 (complex.has_deriv_at_exp (f x)).comp_has_deriv_within_at x hf
id └──────────────────────┘ ┴ ┴ └──────────────────────┘ ┴ └┘
src └──────────────────────┘ └──────────────────────┘
typ └──────────────────────┘ ┴ ┴ └──────────────────────┘ ┴ └┘
doc └──────────────────────┘
87
88 namespace complex
89
90 /-- The complex sine function is everywhere differentiable, with the derivative `cos x`. -/
91 lemma has_deriv_at_sin (x : ℂ) : has_deriv_at sin (cos x) x :=
id ┴ └──────────┘ └─┘ └─┘ ┴ ┴
src ┴ └──────────┘ └─┘ └─┘
typ ┴ └──────────┘ └─┘ └─┘ ┴ ┴
doc └──────────┘
92 begin
st └─────
93 simp only [cos, div_eq_mul_inv],
id └─┘ └────────────┘
src └─────────┘└─┘└┘└────────────┘┴
typ └─────────┘└─┘└┘└────────────┘┴
doc └─────────┘ └┘ ┴
txt └─────────┘ └┘ ┴
par └─────────┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴
st ────────────────────────────────┘└─
94 convert ((((has_deriv_at_id x).neg.mul_const I).cexp.sub
src └──────┘ ┴ └──────────────┘ └──────────
typ └──────┘ ┴ └──────────────┘ └──────────
doc └──────┘ ┴ └──────────────┘ └──────────
txt └──────┘ ┴ └──────────────┘ └──────────
par └──────┘ ┴ └──────────────┘ └──────────
pid ┴ ┴ └──────────────┘ └──────────
st ───────────────────────────────────────────────────────────
95 ((has_deriv_at_id x).mul_const I).cexp).mul_const I).mul_const (2:ℂ)⁻¹,
id └─────────────┘ ┴ ┴ └┘
src ───┘ └─────────────┘┴ └──────────┘ └────────────────┘┴└──────────┘ └┘ ┴└┘
typ ───┘ └─────────────┘┴┴└──────────┘ └────────────────┘┴└──────────┘ └┘ ┴└┘
doc ───┘ ┴ └──────────┘ └────────────────┘ └──────────┘ └┘ ┴
txt ───┘ ┴ └──────────┘ └────────────────┘ └──────────┘ └┘ ┴
par ───┘ ┴ └──────────┘ └────────────────┘ └──────────┘ └┘ ┴
pid ───┘ ┴ └──────────┘ └────────────────┘ └──────────┘ └┘ ┴
st ─────────────────────────────────────────────────────────────────────────┘└─
96 simp only [function.comp, id],
id └───────────┘ └┘
src └─────────┘└───────────┘└┘└┘┴
typ └─────────┘└───────────┘└┘└┘┴
doc └─────────┘ └┘ ┴
txt └─────────┘ └┘ ┴
par └─────────┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴
st ──────────────────────────────┘└─
97 rw [add_comm, one_mul, mul_comm (_ - _), mul_sub, mul_left_comm, ← mul_assoc, ← mul_assoc,
id └──────┘ └─────┘ └──────┘ ┴ └─────┘ └───────────┘ └───────┘ └───────┘
src └──┘└──────┘└┘└─────┘└┘└──────┘┴ └┘┴└───┘└─────┘└┘└───────────┘└──┘└───────┘└──┘└───────┘└─
typ └──┘└──────┘└┘└─────┘└┘└──────┘┴ └┘┴└───┘└─────┘└┘└───────────┘└──┘└───────┘└──┘└───────┘└─
doc └──┘ └┘ └┘ ┴ └┘ └───┘ └┘ └──┘ └──┘ └─
txt └──┘ └┘ └┘ ┴ └┘ └───┘ └┘ └──┘ └──┘ └─
par └──┘ └┘ └┘ ┴ └┘ └───┘ └┘ └──┘ └──┘ └─
pid └┘ └┘ └┘ ┴ └┘ └───┘ └┘ └──┘ └──┘ └─
st ─────────────┘└───────┘└────────────────┘└───────┘└─────────────┘└───────────┘└───────────┘└─
98 I_mul_I, mul_assoc (-1:ℂ), I_mul_I, neg_one_mul, neg_neg, one_mul, neg_one_mul, sub_neg_eq_add]
id └─────┘ └───────┘ ┴ └─────┘ └─────────┘ └─────┘ └─────┘ └─────────┘ └────────────┘
src ───┘└─────┘└┘└───────┘┴ ┴└┘ └─┘└─────┘└┘└─────────┘└┘└─────┘└┘└─────┘└┘└─────────┘└┘└────────────┘└┘
typ ───┘└─────┘└┘└───────┘┴ ┴└┘ └─┘└─────┘└┘└─────────┘└┘└─────┘└┘└─────┘└┘└─────────┘└┘└────────────┘└┘
doc ───┘ └┘ ┴ └┘ └─┘ └┘└─────────┘└┘ └┘ └┘└─────────┘└┘ └┘
txt ───┘ └┘ ┴ └┘ └─┘ └┘ └┘ └┘ └┘ └┘ └┘
par ───┘ └┘ ┴ └┘ └─┘ └┘ └┘ └┘ └┘ └┘ └┘
pid ───┘ └┘ ┴ └┘ └─┘ └┘ └┘ └┘ └┘ └┘ ┴┴
st ──────────┘└────────────────┘└───────┘└───────────┘└───────┘└───────┘└───────────┘└──────────────┘┴┴
99 end
st └─┘
100
101 lemma differentiable_sin : differentiable ℂ sin :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
102 λx, (has_deriv_at_sin x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
doc └──────────────┘
103
104 @[simp] lemma deriv_sin : deriv sin = cos :=
id └───┘ └─┘ ┴ └─┘
src └───┘ └─┘ ┴ └─┘
typ └───┘ └─┘ ┴ └─┘
doc └──┘ └───┘
st ┴
105 funext $ λ x, (has_deriv_at_sin x).deriv
id └────┘ ┴ └──────────────┘ ┴ └───┘
src └────┘ └──────────────┘ └───┘
typ └────┘ ┴ └──────────────┘ ┴ └───┘
doc └──────────────┘
st └──────────────┘
106
107 lemma continuous_sin : continuous sin :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
108 differentiable_sin.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
109
110 /-- The complex cosine function is everywhere differentiable, with the derivative `-sin x`. -/
111 lemma has_deriv_at_cos (x : ℂ) : has_deriv_at cos (-sin x) x :=
id ┴ └──────────┘ └─┘ ┴└─┘ ┴ ┴
src ┴ └──────────┘ └─┘ ┴└─┘
typ ┴ └──────────┘ └─┘ ┴└─┘ ┴ ┴
doc └──────────┘
112 begin
st └─────
113 simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul],
id └─┘ └────────────┘ └────────────────┘
src └─────────┘└─┘└┘└────────────┘└┘└────────────────┘┴
typ └─────────┘└─┘└┘└────────────┘└┘└────────────────┘┴
doc └─────────┘ └┘ └┘ ┴
txt └─────────┘ └┘ └┘ ┴
par └─────────┘ └┘ └┘ ┴
pid ┴└──┘└┘ └┘ └┘ ┴
st ────────────────────────────────────────────────────┘└─
114 convert (((has_deriv_at_id x).mul_const I).cexp.add
src └──────┘ ┴ └──────────┘ └──────────
typ └──────┘ ┴ └──────────┘ └──────────
doc └──────┘ ┴ └──────────┘ └──────────
txt └──────┘ ┴ └──────────┘ └──────────
par └──────┘ ┴ └──────────┘ └──────────
pid ┴ ┴ └──────────┘ └──────────
st ──────────────────────────────────────────────────────
115 ((has_deriv_at_id x).neg.mul_const I).cexp).mul_const (2:ℂ)⁻¹,
id └─────────────┘ ┴ ┴ └┘
src ───┘ └─────────────┘┴ └──────────────┘┴└────────────────┘ └┘ ┴└┘
typ ───┘ └─────────────┘┴┴└──────────────┘┴└────────────────┘ └┘ ┴└┘
doc ───┘ ┴ └──────────────┘ └────────────────┘ └┘ ┴
txt ───┘ ┴ └──────────────┘ └────────────────┘ └┘ ┴
par ───┘ ┴ └──────────────┘ └────────────────┘ └┘ ┴
pid ───┘ ┴ └──────────────┘ └────────────────┘ └┘ ┴
st ────────────────────────────────────────────────────────────────┘└─
116 simp only [function.comp, id],
id └───────────┘ └┘
src └─────────┘└───────────┘└┘└┘┴
typ └─────────┘└───────────┘└┘└┘┴
doc └─────────┘ └┘ ┴
txt └─────────┘ └┘ ┴
par └─────────┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴
st ──────────────────────────────┘└─
117 rw [one_mul, neg_one_mul, neg_sub, mul_comm, mul_sub, sub_eq_add_neg, neg_mul_eq_neg_mul]
id └─────┘ └─────────┘ └─────┘ └──────┘ └─────┘ └────────────┘ └────────────────┘
src └──┘└─────┘└┘└─────────┘└┘└─────┘└┘└──────┘└┘└─────┘└┘└────────────┘└┘└────────────────┘└┘
typ └──┘└─────┘└┘└─────────┘└┘└─────┘└┘└──────┘└┘└─────┘└┘└────────────┘└┘└────────────────┘└┘
doc └──┘ └┘└─────────┘└┘ └┘ └┘ └┘ └┘ └┘
txt └──┘ └┘ └┘ └┘ └┘ └┘ └┘ └┘
par └──┘ └┘ └┘ └┘ └┘ └┘ └┘ └┘
pid └┘ └┘ └┘ └┘ └┘ └┘ └┘ ┴┴
st ────────────┘└───────────┘└───────┘└────────┘└───────┘└──────────────┘└──────────────────┘┴┴
118 end
st └─┘
119
120 lemma differentiable_cos : differentiable ℂ cos :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
121 λx, (has_deriv_at_cos x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
doc └──────────────┘
122
123 lemma deriv_cos {x : ℂ} : deriv cos x = -sin x :=
id ┴ └───┘ └─┘ ┴ ┴ ┴└─┘ ┴
src ┴ └───┘ └─┘ ┴ ┴└─┘
typ ┴ └───┘ └─┘ ┴ ┴ ┴└─┘ ┴
doc └───┘
124 (has_deriv_at_cos x).deriv
id └──────────────┘ ┴ └───┘
src └──────────────┘ └───┘
typ └──────────────┘ ┴ └───┘
doc └──────────────┘
125
126 @[simp] lemma deriv_cos' : deriv cos = (λ x, -sin x) :=
id └───┘ └─┘ ┴ ┴ ┴└─┘ ┴
src └───┘ └─┘ ┴ ┴└─┘
typ └───┘ └─┘ ┴ ┴ ┴└─┘ ┴
doc └──┘ └───┘
127 funext $ λ x, deriv_cos
id └────┘ ┴ └───────┘
src └────┘ └───────┘
typ └────┘ ┴ └───────┘
128
129 lemma continuous_cos : continuous cos :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
130 differentiable_cos.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
131
132 lemma continuous_tan : continuous (λ x : {x // cos x ≠ 0}, tan x) :=
id └────────┘ ┴┴ └─┘ ┴ ┴ └─┘ ┴
src └────────┘ ┴ └─┘ ┴ └─┘
typ └────────┘ ┴┴ └─┘ ┴ ┴ └─┘ ┴
doc └────────┘
133 (continuous_sin.comp continuous_subtype_val).mul
id └────────────┘└───┘ └────────────────────┘ └─┘
src └────────────┘└───┘ └────────────────────┘ └─┘
typ └────────────┘└───┘ └────────────────────┘ └─┘
134 (continuous.inv subtype.property (continuous_cos.comp continuous_subtype_val))
id └────────────┘ └──────────────┘ └────────────┘└───┘ └────────────────────┘
src └────────────┘ └──────────────┘ └────────────┘└───┘ └────────────────────┘
typ └────────────┘ └──────────────┘ └────────────┘└───┘ └────────────────────┘
135
136 /-- The complex hyperbolic sine function is everywhere differentiable, with the derivative `sinh x`. -/
137 lemma has_deriv_at_sinh (x : ℂ) : has_deriv_at sinh (cosh x) x :=
id ┴ └──────────┘ └──┘ └──┘ ┴ ┴
src ┴ └──────────┘ └──┘ └──┘
typ ┴ └──────────┘ └──┘ └──┘ ┴ ┴
doc └──────────┘
138 begin
st └─────
139 simp only [cosh, div_eq_mul_inv],
id └──┘ └────────────┘
src └─────────┘└──┘└┘└────────────┘┴
typ └─────────┘└──┘└┘└────────────┘┴
doc └─────────┘ └┘ ┴
txt └─────────┘ └┘ ┴
par └─────────┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴
st ─────────────────────────────────┘└─
140 convert ((has_deriv_at_exp x).sub (has_deriv_at_id x).neg.cexp).mul_const (2:ℂ)⁻¹,
id └──────────────┘ └─────────────┘ ┴ └┘
src └──────┘ └──────────────┘┴ └────┘ └─────────────┘┴ └────────────────────┘ └┘ ┴└┘
typ └──────┘ └──────────────┘┴ └────┘ └─────────────┘┴┴└────────────────────┘ └┘ ┴└┘
doc └──────┘ └──────────────┘┴ └────┘ ┴ └────────────────────┘ └┘ ┴
txt └──────┘ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
par └──────┘ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
pid ┴ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
st ──────────────────────────────────────────────────────────────────────────────────┘└─
141 rw [id, neg_one_mul, neg_neg]
id └┘ └─────────┘ └─────┘
src └──┘└┘└┘└─────────┘└┘└─────┘└┘
typ └──┘└┘└┘└─────────┘└┘└─────┘└┘
doc └──┘ └┘└─────────┘└┘ └┘
txt └──┘ └┘ └┘ └┘
par └──┘ └┘ └┘ └┘
pid └┘ └┘ └┘ ┴┴
st ───────┘└───────────┘└───────┘┴┴
142 end
st └─┘
143
144 lemma differentiable_sinh : differentiable ℂ sinh :=
id └────────────┘ ┴ └──┘
src └────────────┘ ┴ └──┘
typ └────────────┘ ┴ └──┘
doc └────────────┘
145 λx, (has_deriv_at_sinh x).differentiable_at
id ┴ └───────────────┘ ┴ └───────────────┘
src └───────────────┘ └───────────────┘
typ ┴ └───────────────┘ ┴ └───────────────┘
doc └───────────────┘
146
147 @[simp] lemma deriv_sinh : deriv sinh = cosh :=
id └───┘ └──┘ ┴ └──┘
src └───┘ └──┘ ┴ └──┘
typ └───┘ └──┘ ┴ └──┘
doc └──┘ └───┘
148 funext $ λ x, (has_deriv_at_sinh x).deriv
id └────┘ ┴ └───────────────┘ ┴ └───┘
src └────┘ └───────────────┘ └───┘
typ └────┘ ┴ └───────────────┘ ┴ └───┘
doc └───────────────┘
149
150 lemma continuous_sinh : continuous sinh :=
id └────────┘ └──┘
src └────────┘ └──┘
typ └────────┘ └──┘
doc └────────┘
151 differentiable_sinh.continuous
id └─────────────────┘└─────────┘
src └─────────────────┘└─────────┘
typ └─────────────────┘└─────────┘
152
153 /-- The complex hyperbolic cosine function is everywhere differentiable, with the derivative `cosh x`. -/
154 lemma has_deriv_at_cosh (x : ℂ) : has_deriv_at cosh (sinh x) x :=
id ┴ └──────────┘ └──┘ └──┘ ┴ ┴
src ┴ └──────────┘ └──┘ └──┘
typ ┴ └──────────┘ └──┘ └──┘ ┴ ┴
doc └──────────┘
155 begin
st └─────
156 simp only [sinh, div_eq_mul_inv],
id └──┘ └────────────┘
src └─────────┘└──┘└┘└────────────┘┴
typ └─────────┘└──┘└┘└────────────┘┴
doc └─────────┘ └┘ ┴
txt └─────────┘ └┘ ┴
par └─────────┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴
st ─────────────────────────────────┘└─
157 convert ((has_deriv_at_exp x).add (has_deriv_at_id x).neg.cexp).mul_const (2:ℂ)⁻¹,
id └──────────────┘ └─────────────┘ ┴ └┘
src └──────┘ └──────────────┘┴ └────┘ └─────────────┘┴ └────────────────────┘ └┘ ┴└┘
typ └──────┘ └──────────────┘┴ └────┘ └─────────────┘┴┴└────────────────────┘ └┘ ┴└┘
doc └──────┘ └──────────────┘┴ └────┘ ┴ └────────────────────┘ └┘ ┴
txt └──────┘ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
par └──────┘ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
pid ┴ ┴ └────┘ ┴ └────────────────────┘ └┘ ┴
st ──────────────────────────────────────────────────────────────────────────────────┘└─
158 rw [id, neg_one_mul, sub_eq_add_neg]
id └┘ └─────────┘ └────────────┘
src └──┘└┘└┘└─────────┘└┘└────────────┘└┘
typ └──┘└┘└┘└─────────┘└┘└────────────┘└┘
doc └──┘ └┘└─────────┘└┘ └┘
txt └──┘ └┘ └┘ └┘
par └──┘ └┘ └┘ └┘
pid └┘ └┘ └┘ ┴┴
st ───────┘└───────────┘└──────────────┘┴┴
159 end
st └─┘
160
161 lemma differentiable_cosh : differentiable ℂ cosh :=
id └────────────┘ ┴ └──┘
src └────────────┘ ┴ └──┘
typ └────────────┘ ┴ └──┘
doc └────────────┘
162 λx, (has_deriv_at_cosh x).differentiable_at
id ┴ └───────────────┘ ┴ └───────────────┘
src └───────────────┘ └───────────────┘
typ ┴ └───────────────┘ ┴ └───────────────┘
doc └───────────────┘
163
164 @[simp] lemma deriv_cosh : deriv cosh = sinh :=
id └───┘ └──┘ ┴ └──┘
src └───┘ └──┘ ┴ └──┘
typ └───┘ └──┘ ┴ └──┘
doc └──┘ └───┘
165 funext $ λ x, (has_deriv_at_cosh x).deriv
id └────┘ ┴ └───────────────┘ ┴ └───┘
src └────┘ └───────────────┘ └───┘
typ └────┘ ┴ └───────────────┘ ┴ └───┘
doc └───────────────┘
166
167 lemma continuous_cosh : continuous cosh :=
id └────────┘ └──┘
src └────────┘ └──┘
typ └────────┘ └──┘
doc └────────┘
168 differentiable_cosh.continuous
id └─────────────────┘└─────────┘
src └─────────────────┘└─────────┘
typ └─────────────────┘└─────────┘
169
170 end complex
171
172 namespace real
173
174 variables {x y z : ℝ}
id ┴
src ┴
typ ┴
175
176 lemma has_deriv_at_exp (x : ℝ) : has_deriv_at exp (exp x) x :=
id ┴ └──────────┘ └─┘ └─┘ ┴ ┴
src ┴ └──────────┘ └─┘ └─┘
typ ┴ └──────────┘ └─┘ └─┘ ┴ ┴
doc └──────────┘
177 has_deriv_at_real_of_complex (complex.has_deriv_at_exp x)
id └──────────────────────────┘ └──────────────────────┘ ┴
src └──────────────────────────┘ └──────────────────────┘
typ └──────────────────────────┘ └──────────────────────┘ ┴
doc └──────────────────────────┘ └──────────────────────┘
178
179 lemma differentiable_exp : differentiable ℝ exp :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
180 λx, (has_deriv_at_exp x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src ┴ └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
181
182 @[simp] lemma deriv_exp : deriv exp = exp :=
id └───┘ └─┘ ┴ └─┘
src └───┘ └─┘ ┴ └─┘
typ └───┘ └─┘ ┴ └─┘
doc └──┘ └───┘
183 funext $ λ x, (has_deriv_at_exp x).deriv
id └────┘ ┴ └──────────────┘ ┴ └───┘
src └────┘ └──────────────┘ └───┘
typ └────┘ ┴ └──────────────┘ ┴ └───┘
184
185 @[simp] lemma iter_deriv_exp : ∀ n : ℕ, (deriv^[n] exp) = exp
id ┴ ┴ └───┘└┘┴┴ └─┘ ┴ └─┘
src ┴ └───┘└┘ ┴ └─┘ ┴ └─┘
typ ┴ ┴ └───┘└┘┴┴ └─┘ ┴ └─┘
doc └──┘ └───┘
186 | 0 := rfl
id └─┘
src └─┘
typ └─┘
187 | (n+1) := by rw [nat.iterate_succ, deriv_exp, iter_deriv_exp n]
id ┴ └──────────────┘ └───────┘ └────────────┘ ┴
src ┴ └──┘└──────────────┘└┘└───────┘└┘ ┴ └─
typ ┴ └──┘└──────────────┘└┘└───────┘└┘└────────────┘┴┴└─
doc └──┘ └┘ └┘ ┴ └─
txt └──┘ └┘ └┘ ┴ └─
par └──┘ └┘ └┘ ┴ └─
pid └┘ └┘ └┘ ┴ ┴└
st └───────────────────┘└─────────┘└────────────────┘┴└
188
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
189 lemma continuous_exp : continuous exp :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
190 differentiable_exp.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
191
192 lemma has_deriv_at_sin (x : ℝ) : has_deriv_at sin (cos x) x :=
id ┴ └──────────┘ └─┘ └─┘ ┴ ┴
src ┴ └──────────┘ └─┘ └─┘
typ ┴ └──────────┘ └─┘ └─┘ ┴ ┴
doc └──────────┘
193 has_deriv_at_real_of_complex (complex.has_deriv_at_sin x)
id └──────────────────────────┘ └──────────────────────┘ ┴
src └──────────────────────────┘ └──────────────────────┘
typ └──────────────────────────┘ └──────────────────────┘ ┴
doc └──────────────────────────┘ └──────────────────────┘
194
195 lemma differentiable_sin : differentiable ℝ sin :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
196 λx, (has_deriv_at_sin x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
197
198 @[simp] lemma deriv_sin : deriv sin = cos :=
id └───┘ └─┘ ┴ └─┘
src └───┘ └─┘ ┴ └─┘
typ └───┘ └─┘ ┴ └─┘
doc └──┘ └───┘
199 funext $ λ x, (has_deriv_at_sin x).deriv
id └────┘ ┴ └──────────────┘ ┴ └───┘
src └────┘ └──────────────┘ └───┘
typ └────┘ ┴ └──────────────┘ ┴ └───┘
200
201 lemma continuous_sin : continuous sin :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
202 differentiable_sin.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
203
204 lemma has_deriv_at_cos (x : ℝ) : has_deriv_at cos (-sin x) x :=
id ┴ └──────────┘ └─┘ ┴└─┘ ┴ ┴
src ┴ └──────────┘ └─┘ ┴└─┘
typ ┴ └──────────┘ └─┘ ┴└─┘ ┴ ┴
doc └──────────┘
205 (has_deriv_at_real_of_complex (complex.has_deriv_at_cos x) : _)
id └──────────────────────────┘ └──────────────────────┘ ┴
src └──────────────────────────┘ └──────────────────────┘
typ └──────────────────────────┘ └──────────────────────┘ ┴
doc └──────────────────────────┘ └──────────────────────┘
206
207 lemma differentiable_cos : differentiable ℝ cos :=
id └────────────┘ ┴ └─┘
src └────────────┘ ┴ └─┘
typ └────────────┘ ┴ └─┘
doc └────────────┘
208 λx, (has_deriv_at_cos x).differentiable_at
id ┴ └──────────────┘ ┴ └───────────────┘
src └──────────────┘ └───────────────┘
typ ┴ └──────────────┘ ┴ └───────────────┘
209
210 lemma deriv_cos : deriv cos x = - sin x :=
id └───┘ └─┘ ┴ ┴ ┴ └─┘ ┴
src └───┘ └─┘ ┴ ┴ └─┘
typ └───┘ └─┘ ┴ ┴ ┴ └─┘ ┴
doc └───┘
211 (has_deriv_at_cos x).deriv
id └──────────────┘ ┴ └───┘
src └──────────────┘ └───┘
typ └──────────────┘ ┴ └───┘
212
213 @[simp] lemma deriv_cos' : deriv cos = (λ x, - sin x) :=
id └───┘ └─┘ ┴ ┴ ┴ └─┘ ┴
src └───┘ └─┘ ┴ ┴ └─┘
typ └───┘ └─┘ ┴ ┴ ┴ └─┘ ┴
doc └──┘ └───┘
214 funext $ λ _, deriv_cos
id └────┘ ┴ └───────┘
src └────┘ └───────┘
typ └────┘ ┴ └───────┘
215
216 lemma continuous_cos : continuous cos :=
id └────────┘ └─┘
src └────────┘ └─┘
typ └────────┘ └─┘
doc └────────┘
217 differentiable_cos.continuous
id └────────────────┘└─────────┘
src └────────────────┘└─────────┘
typ └────────────────┘└─────────┘
218
219 lemma continuous_tan : continuous (λ x : {x // cos x ≠ 0}, tan x) :=
id └────────┘ ┴┴ └─┘ ┴ ┴ └─┘ ┴
src └────────┘ ┴ └─┘ ┴ └─┘
typ └────────┘ ┴┴ └─┘ ┴ ┴ └─┘ ┴
doc └────────┘
220 by simp only [tan_eq_sin_div_cos]; exact
id └────────────────┘
src └─────────┘└────────────────┘┴ └─────
typ └─────────┘└────────────────┘┴ └─────
doc └─────────┘ ┴ └─────
txt └─────────┘ ┴ └─────
par └─────────┘ ┴ └─────
pid ┴└──┘└┘ ┴ └
st └──────────────────────────────────────
221 (continuous_sin.comp continuous_subtype_val).mul
id └─────────────────┘
src ─┘ └─────────────────┘┴ └─────
typ ─┘ └─────────────────┘┴ └─────
doc ─┘ ┴ └─────
txt ─┘ ┴ └─────
par ─┘ ┴ └─────
pid ─┘ ┴ └─────
st ───────────────────────────────────────────────────
222 (continuous.inv subtype.property
id └────────────┘ └──────────────┘
src ─┘ └────────────┘┴└──────────────┘└
typ ─┘ └────────────┘┴└──────────────┘└
doc ─┘ ┴ └
txt ─┘ ┴ └
par ─┘ ┴ └
pid ─┘ ┴ └
st ───────────────────────────────────
223 (continuous_cos.comp continuous_subtype_val))
id └─────────────────┘ └────────────────────┘
src ───┘ └─────────────────┘┴└────────────────────┘└──
typ ───┘ └─────────────────┘┴└────────────────────┘└──
doc ───┘ ┴ └──
txt ───┘ ┴ └──
par ───┘ ┴ └──
pid ───┘ ┴ └┘└
st ──────────────────────────────────────────────────
224
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
225 lemma has_deriv_at_sinh (x : ℝ) : has_deriv_at sinh (cosh x) x :=
id ┴ └──────────┘ └──┘ └──┘ ┴ ┴
src ┴ └──────────┘ └──┘ └──┘
typ ┴ └──────────┘ └──┘ └──┘ ┴ ┴
doc └──────────┘
226 has_deriv_at_real_of_complex (complex.has_deriv_at_sinh x)
id └──────────────────────────┘ └───────────────────────┘ ┴
src └──────────────────────────┘ └───────────────────────┘
typ └──────────────────────────┘ └───────────────────────┘ ┴
doc └──────────────────────────┘ └───────────────────────┘
227
228 lemma differentiable_sinh : differentiable ℝ sinh :=
id └────────────┘ ┴ └──┘
src └────────────┘ ┴ └──┘
typ └────────────┘ ┴ └──┘
doc └────────────┘
229 λx, (has_deriv_at_sinh x).differentiable_at
id ┴ └───────────────┘ ┴ └───────────────┘
src └───────────────┘ └───────────────┘
typ ┴ └───────────────┘ ┴ └───────────────┘
230
231 @[simp] lemma deriv_sinh : deriv sinh = cosh :=
id └───┘ └──┘ ┴ └──┘
src └───┘ └──┘ ┴ └──┘
typ └───┘ └──┘ ┴ └──┘
doc └──┘ └───┘
232 funext $ λ x, (has_deriv_at_sinh x).deriv
id └────┘ ┴ └───────────────┘ ┴ └───┘
src └────┘ └───────────────┘ └───┘
typ └────┘ ┴ └───────────────┘ ┴ └───┘
233
234 lemma continuous_sinh : continuous sinh :=
id └────────┘ └──┘
src └────────┘ └──┘
typ └────────┘ └──┘
doc └────────┘
235 differentiable_sinh.continuous
id └─────────────────┘└─────────┘
src └─────────────────┘└─────────┘
typ └─────────────────┘└─────────┘
236
237 lemma has_deriv_at_cosh (x : ℝ) : has_deriv_at cosh (sinh x) x :=
id ┴ └──────────┘ └──┘ └──┘ ┴ ┴
src ┴ └──────────┘ └──┘ └──┘
typ ┴ └──────────┘ └──┘ └──┘ ┴ ┴
doc └──────────┘
238 has_deriv_at_real_of_complex (complex.has_deriv_at_cosh x)
id └──────────────────────────┘ └───────────────────────┘ ┴
src └──────────────────────────┘ └───────────────────────┘
typ └──────────────────────────┘ └───────────────────────┘ ┴
doc └──────────────────────────┘ └───────────────────────┘
239
240 lemma differentiable_cosh : differentiable ℝ cosh :=
id └────────────┘ ┴ └──┘
src └────────────┘ ┴ └──┘
typ └────────────┘ ┴ └──┘
doc └────────────┘
241 λx, (has_deriv_at_cosh x).differentiable_at
id ┴ └───────────────┘ ┴ └───────────────┘
src └───────────────┘ └───────────────┘
typ ┴ └───────────────┘ ┴ └───────────────┘
242
243 @[simp] lemma deriv_cosh : deriv cosh = sinh :=
id └───┘ └──┘ ┴ └──┘
src └───┘ └──┘ ┴ └──┘
typ └───┘ └──┘ ┴ └──┘
doc └──┘ └───┘
244 funext $ λ x, (has_deriv_at_cosh x).deriv
id └────┘ ┴ └───────────────┘ ┴ └───┘
src └────┘ └───────────────┘ └───┘
typ └────┘ ┴ └───────────────┘ ┴ └───┘
245
246 lemma continuous_cosh : continuous cosh :=
id └────────┘ └──┘
src └────────┘ └──┘
typ └────────┘ └──┘
doc └────────┘
247 differentiable_cosh.continuous
id └─────────────────┘└─────────┘
src └─────────────────┘└─────────┘
typ └─────────────────┘└─────────┘
248
249 lemma exists_exp_eq_of_pos {x : ℝ} (hx : 0 < x) : ∃ y, exp y = x :=
id ┴ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴ ┴┴ └─┘ ┴ ┴ ┴
250 have ∀ {z:ℝ}, 1 ≤ z → z ∈ set.range exp,
id ┴ ┴ ┴ ┴ ┴ └───────┘ └─┘
src ┴ ┴ ┴ └───────┘ └─┘
typ ┴ ┴ ┴ ┴ ┴ └───────┘ └─┘
doc └───────┘
251 from λ z hz, intermediate_value_univ 0 (z - 1) continuous_exp
id ┴ └┘ └─────────────────────┘ ┴ ┴ └────────────┘
src └─────────────────────┘ ┴ └────────────┘
typ ┴ └┘ └─────────────────────┘ ┴ ┴ └────────────┘
doc └─────────────────────┘
252 ⟨by simpa, by simpa using add_one_le_exp_of_nonneg (sub_nonneg.2 hz)⟩,
id └──────────────────────┘ └────────┘ └┘
src └───┘ └──────────┘└──────────────────────┘┴ └────────┘└─┘ ┴
typ └───┘ └──────────┘└──────────────────────┘┴ └────────┘└─┘└┘┴
doc └───┘ └──────────┘ ┴ └─┘ ┴
txt └───┘ └──────────┘ ┴ └─┘ ┴
par └───┘ └──────────┘ ┴ └─┘ ┴
pid ┴└────┘ ┴ └─┘ ┴
st └────┘ └─────────────────────────────────────────────────────┘
253 match le_total x 1 with
id └──────┘ ┴
src └──────┘
typ └──────┘ ┴
254 | (or.inl hx1) := let ⟨y, hy⟩ := this (one_le_inv hx hx1) in
id └────┘ └─┘ └─┘ ┴ └──┘ └────────┘ └┘
src └────┘ └────────┘
typ └────┘ └─┘ └─┘ ┴ └──┘ └────────┘ └┘
255 ⟨-y, by rw [exp_neg, hy, inv_inv']⟩
id ┴ └─────┘ └┘ └──────┘
src ┴ └──┘└─────┘└┘ └┘└──────┘┴
typ ┴ └──┘└─────┘└┘└┘└┘└──────┘┴
doc └──┘ └┘ └┘ ┴
txt └──┘ └┘ └┘ ┴
par └──┘ └┘ └┘ ┴
pid └┘ └┘ └┘ ┴
st └──────────┘└──┘└────────┘┴
256 | (or.inr hx1) := this hx1
id └────┘ └─┘ └──┘
src └────┘
typ └────┘ └─┘ └──┘
257 end
258
259 /-- The real logarithm function, equal to `0` for `x ≤ 0` and to the inverse of the exponential
260 for `x > 0`. -/
261 noncomputable def log (x : ℝ) : ℝ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
262 if hx : 0 < x then classical.some (exists_exp_eq_of_pos hx) else 0
id └┘ ┴ ┴ └────────────┘ └──────────────────┘ └┘ ┴
src └┘ ┴ └────────────┘ └──────────────────┘ ┴
typ └┘ ┴ ┴ └────────────┘ └──────────────────┘ └┘ ┴
263
264 lemma exp_log {x : ℝ} (hx : 0 < x) : exp (log x) = x :=
id ┴ ┴ ┴ └─┘ └─┘ ┴ ┴ ┴
src ┴ ┴ └─┘ └─┘ ┴
typ ┴ ┴ ┴ └─┘ └─┘ ┴ ┴ ┴
doc └─┘
265 by rw [log, dif_pos hx]; exact classical.some_spec (exists_exp_eq_of_pos hx)
id └─┘ └─────┘ └┘ └─────────────────┘ └──────────────────┘ └┘
src └──┘└─┘└┘└─────┘┴ ┴ └────┘└─────────────────┘┴ └──────────────────┘┴ └─
typ └──┘└─┘└┘└─────┘┴└┘┴ └────┘└─────────────────┘┴ └──────────────────┘┴└┘└─
doc └──┘└─┘└┘ ┴ ┴ └────┘ ┴ ┴ └─
txt └──┘ └┘ ┴ ┴ └────┘ ┴ ┴ └─
par └──┘ └┘ ┴ ┴ └────┘ ┴ ┴ └─
pid └┘ └┘ ┴ ┴ ┴ ┴ ┴ ┴└
st └──────┘└──────────┘┴└─────────────────────────────────────────────────────
266
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
267 @[simp] lemma log_exp (x : ℝ) : log (exp x) = x :=
id ┴ └─┘ └─┘ ┴ ┴ ┴
src ┴ └─┘ └─┘ ┴
typ ┴ └─┘ └─┘ ┴ ┴ ┴
doc └──┘ └─┘
268 exp_injective $ exp_log (exp_pos x)
id └───────────┘ └─────┘ └─────┘ ┴
src └───────────┘ └─────┘ └─────┘
typ └───────────┘ └─────┘ └─────┘ ┴
269
270 @[simp] lemma log_zero : log 0 = 0 :=
id └─┘ ┴
src └─┘ ┴
typ └─┘ ┴
doc └──┘ └─┘
271 by simp [log, lt_irrefl]
id └─┘ └───────┘
src └────┘└─┘└┘└───────┘└─
typ └────┘└─┘└┘└───────┘└─
doc └────┘└─┘└┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └──────────────────────
272
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
273 @[simp] lemma log_one : log 1 = 0 :=
id └─┘ ┴
src └─┘ ┴
typ └─┘ ┴
doc └──┘ └─┘
274 exp_injective $ by rw [exp_log zero_lt_one, exp_zero]
id └───────────┘ └─────┘ └─────────┘ └──────┘
src └───────────┘ └──┘└─────┘┴└─────────┘└┘└──────┘└─
typ └───────────┘ └──┘└─────┘┴└─────────┘└┘└──────┘└─
doc └──┘ ┴ └┘ └─
txt └──┘ ┴ └┘ └─
par └──┘ ┴ └┘ └─
pid └┘ ┴ └┘ ┴└
st └──────────────────────┘└────────┘┴└
275
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
276 lemma log_mul {x y : ℝ} (hx : 0 < x) (hy : 0 < y) : log (x * y) = log x + log y :=
id ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴
doc └─┘ └─┘ └─┘
277 exp_injective $ by rw [exp_log (mul_pos hx hy), exp_add, exp_log hx, exp_log hy]
id └───────────┘ └─────┘ └─────┘ └┘ └┘ └─────┘ └─────┘ └┘ └─────┘ └┘
src └───────────┘ └──┘└─────┘┴ └─────┘┴ ┴ └─┘└─────┘└┘└─────┘┴ └┘└─────┘┴ └─
typ └───────────┘ └──┘└─────┘┴ └─────┘┴└┘┴└┘└─┘└─────┘└┘└─────┘┴└┘└┘└─────┘┴└┘└─
doc └──┘ ┴ ┴ ┴ └─┘ └┘ ┴ └┘ ┴ └─
txt └──┘ ┴ ┴ ┴ └─┘ └┘ ┴ └┘ ┴ └─
par └──┘ ┴ ┴ ┴ └─┘ └┘ ┴ └┘ ┴ └─
pid └┘ ┴ ┴ ┴ └─┘ └┘ ┴ └┘ ┴ ┴└
st └──────────────────────────┘└───────┘└──────────┘└──────────┘┴└
278
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
279 lemma log_le_log {x y : ℝ} (h : 0 < x) (h₁ : 0 < y) : real.log x ≤ real.log y ↔ x ≤ y :=
id ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ └──────┘ ┴ └──────┘ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ └──────┘ ┴ ┴ └──────┘ ┴ ┴ ┴ ┴ ┴
doc └──────┘ └──────┘
280 ⟨λ h₂, by rwa [←real.exp_le_exp, real.exp_log h, real.exp_log h₁] at h₂, λ h₂,
id └┘ └─────────────┘ └──────────┘ ┴ └──────────┘ └┘ └┘
src └────┘└─────────────┘└┘└──────────┘┴ └┘└──────────┘┴ └─────┘
typ └┘ └────┘└─────────────┘└┘└──────────┘┴┴└┘└──────────┘┴└┘└─────┘ └┘
doc └────┘ └┘ ┴ └┘ ┴ └─────┘
txt └────┘ └┘ ┴ └┘ ┴ └─────┘
par └────┘ └┘ ┴ └┘ ┴ └─────┘
pid └─┘ └┘ ┴ └┘ ┴ ┴└────┘
st └────────────────────┘└──────────────┘└───────────────┘┴└────┘
281 (real.exp_le_exp).1 $ by rwa [real.exp_log h₁, real.exp_log h]⟩
id └─────────────┘ ┴ └──────────┘ └┘ └──────────┘ ┴
src └─────────────┘ ┴ └───┘└──────────┘┴ └┘└──────────┘┴ ┴
typ └─────────────┘ ┴ └───┘└──────────┘┴└┘└┘└──────────┘┴┴┴
doc └───┘ ┴ └┘ ┴ ┴
txt └───┘ ┴ └┘ ┴ ┴
par └───┘ ┴ └┘ ┴ ┴
pid └┘ ┴ └┘ ┴ ┴
st └───────────────────┘└──────────────┘┴
282
283 lemma log_lt_log (hx : 0 < x) : x < y → log x < log y :=
id ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴
src ┴ ┴ └─┘ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴
doc └─┘ └─┘
284 by { intro h, rwa [← exp_lt_exp, exp_log hx, exp_log (lt_trans hx h)] }
id └────────┘ └─────┘ └┘ └─────┘ └──────┘ └┘ ┴
src └─────┘ └─────┘└────────┘└┘└─────┘┴ └┘└─────┘┴ └──────┘┴ ┴ └─┘
typ └─────┘ └─────┘└────────┘└┘└─────┘┴└┘└┘└─────┘┴ └──────┘┴└┘┴┴└─┘
doc └─────┘ └─────┘ └┘ ┴ └┘ ┴ ┴ ┴ └─┘
txt └─────┘ └─────┘ └┘ ┴ └┘ ┴ ┴ ┴ └─┘
par └─────┘ └─────┘ └┘ ┴ └┘ ┴ ┴ ┴ └─┘
pid └┘ └──┘ └┘ ┴ └┘ ┴ ┴ ┴ └┘┴
st └────────┘└─────────────────┘└──────────┘└───────────────────────┘┴┴└┘
285
286 lemma log_lt_log_iff (hx : 0 < x) (hy : 0 < y) : log x < log y ↔ x < y :=
id ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ └─┘ ┴ └─┘ ┴ ┴
typ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └─┘ └─┘
287 by { rw [← exp_lt_exp, exp_log hx, exp_log hy] }
id └────────┘ └─────┘ └┘ └─────┘ └┘
src └────┘└────────┘└┘└─────┘┴ └┘└─────┘┴ └┘
typ └────┘└────────┘└┘└─────┘┴└┘└┘└─────┘┴└┘└┘
doc └────┘ └┘ ┴ └┘ ┴ └┘
txt └────┘ └┘ ┴ └┘ ┴ └┘
par └────┘ └┘ ┴ └┘ ┴ └┘
pid └──┘ └┘ ┴ └┘ ┴ ┴┴
st └─────────────────┘└──────────┘└──────────┘┴┴└┘
288
289 lemma log_pos_iff (x : ℝ) : 0 < log x ↔ 1 < x :=
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴
src ┴ ┴ └─┘ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
doc └─┘
290 begin
st └─────
291 by_cases h : 0 < x,
id ┴ ┴
src └───────┘ └───┘┴┴
typ └───────┘ └───┘┴┴┴
doc └───────┘ └───┘ ┴
txt └───────┘ └───┘ ┴
par └───────┘ └───┘ ┴
pid ┴ └───┘ ┴
st ───────────────────┘└─
292 { rw ← log_one, exact log_lt_log_iff (by norm_num) h },
id └─────┘ └────────────┘ ┴
src └───┘└─────┘ └────┘└────────────┘┴ ┴└──────┘└┘ ┴
typ └───┘└─────┘ └────┘└────────────┘┴ ┴└──────┘└┘┴┴
doc └───┘ └────┘ ┴ ┴└──────┘└┘ ┴
txt └───┘ └────┘ ┴ ┴└──────┘└┘ ┴
par └───┘ └────┘ ┴ ┴└──────┘└┘ ┴
pid └─┘ ┴ ┴ └─────────┘ ┴
st ───┘└──────────┘└────────────────────────┘└───────┘└──┘└┘└
293 { rw [log, dif_neg], split, repeat {intro, linarith} }
id └─┘ └─────┘
src └──┘└─┘└┘└─────┘┴ └───┘ └──────┘└───┘└┘└──────┘└┘
typ └──┘└─┘└┘└─────┘┴ └───┘ └──────┘└───┘└┘└──────┘└┘
doc └──┘└─┘└┘ ┴ └───┘ └──────┘└───┘└┘└──────┘└┘
txt └──┘ └┘ ┴ └───┘ └──────┘└───┘└┘└──────┘└┘
par └──┘ └┘ ┴ └───┘ └──────┘└───┘└┘└──────┘└┘
pid └┘ └┘ ┴ └────────────────┘┴
st ──────────┘└───────┘└──────┘└────────┘└───┘└────────┘┴┴└─
294 end
st ──┘
295
296 lemma log_pos : 1 < x → 0 < log x := (log_pos_iff x).2
id ┴ ┴ ┴ └─┘ ┴ └─────────┘ ┴ ┴
src ┴ ┴ └─┘ └─────────┘ ┴
typ ┴ ┴ ┴ └─┘ ┴ └─────────┘ ┴ ┴
doc └─┘
297
298 lemma log_neg_iff (h : 0 < x) : log x < 0 ↔ x < 1 :=
id ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc └─┘
299 by { rw ← log_one, exact log_lt_log_iff h (by norm_num) }
id └─────┘ └────────────┘ ┴
src └───┘└─────┘ └────┘└────────────┘┴ ┴ ┴└──────┘└┘
typ └───┘└─────┘ └────┘└────────────┘┴┴┴ ┴└──────┘└┘
doc └───┘ └────┘ ┴ ┴ ┴└──────┘└┘
txt └───┘ └────┘ ┴ ┴ ┴└──────┘└┘
par └───┘ └────┘ ┴ ┴ ┴└──────┘└┘
pid └─┘ ┴ ┴ ┴ └────────┘┴
st └─────────────┘└──────────────────────────┘└───────┘└┘└┘
300
301 lemma log_neg (h0 : 0 < x) (h1 : x < 1) : log x < 0 := (log_neg_iff h0).2 h1
id ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─────────┘ └┘ ┴ └┘
src ┴ ┴ └─┘ ┴ └─────────┘ ┴
typ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ └─────────┘ └┘ ┴ └┘
doc └─┘
302
303 lemma log_nonneg : 1 ≤ x → 0 ≤ log x :=
id ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ └─┘
typ ┴ ┴ ┴ └─┘ ┴
doc └─┘
304 by { intro, rwa [← log_one, log_le_log], norm_num, linarith }
id └─────┘ └────────┘
src └───┘ └─────┘└─────┘└┘└────────┘┴ └──────┘ └───────┘
typ └───┘ └─────┘└─────┘└┘└────────┘┴ └──────┘ └───────┘
doc └───┘ └─────┘ └┘ ┴ └──────┘ └───────┘
txt └───┘ └─────┘ └┘ ┴ └──────┘ └───────┘
par └───┘ └─────┘ └┘ ┴ └──────┘ └───────┘
pid └──┘ └┘ ┴ ┴
st └──────┘└──────────────┘└──────────┘┴└────────┘└─────────┘└┘
305
306 lemma log_nonpos : x ≤ 1 → log x ≤ 0 :=
id ┴ ┴ └─┘ ┴ ┴
src ┴ └─┘ ┴
typ ┴ ┴ └─┘ ┴ ┴
doc └─┘
307 begin
st └─────
308 intro, by_cases hx : 0 < x,
id ┴ ┴
src └───┘ └───────┘ └───┘┴┴
typ └───┘ └───────┘ └───┘┴┴┴
doc └───┘ └───────┘ └───┘ ┴
txt └───┘ └───────┘ └───┘ ┴
par └───┘ └───────┘ └───┘ ┴
pid ┴ └───┘ ┴
st ──────┘└───────────────────┘└─
309 { rwa [← log_one, log_le_log], exact hx, norm_num },
id └─────┘ └────────┘ └┘
src └─────┘└─────┘└┘└────────┘┴ └────┘ └───────┘
typ └─────┘└─────┘└┘└────────┘┴ └────┘└┘ └───────┘
doc └─────┘ └┘ ┴ └────┘ └───────┘
txt └─────┘ └┘ ┴ └────┘ └───────┘
par └─────┘ └┘ ┴ └────┘ └───────┘
pid └──┘ └┘ ┴ ┴ ┴
st ───┘└────────────┘└──────────┘┴└────────┘└─────────┘└┘└
310 { simp [log, dif_neg hx] }
id └─┘ └─────┘ └┘
src └────┘└─┘└┘└─────┘┴ └┘
typ └────┘└─┘└┘└─────┘┴└┘└┘
doc └────┘└─┘└┘ ┴ └┘
txt └────┘ └┘ ┴ └┘
par └────┘ └┘ ┴ └┘
pid ┴┴ └┘ ┴ ┴┴
st ──────────────────────────┘└─
311 end
st ──┘
312
313 section prove_log_is_continuous
314
315 lemma tendsto_log_one_zero : tendsto log (𝓝 1) (𝓝 0) :=
id └─────┘ └─┘ ┴ ┴
src └─────┘ └─┘ ┴ ┴
typ └─────┘ └─┘ ┴ ┴
doc └─────┘ └─┘ ┴ ┴
316 begin
st └─────
317 rw tendsto_nhds_nhds, assume ε ε0,
id └───────────────┘
src └─┘└───────────────┘ └─────────┘
typ └─┘└───────────────┘ └─────────┘
doc └─┘ └─────────┘
txt └─┘ └─────────┘
par └─┘ └─────────┘
pid ┴ └─────────┘
st ─────────────────────┘└───────────┘└─
318 let δ := min (exp ε - 1) (1 - exp (-ε)),
id └─┘ ┴ └─┘ ┴┴
src └───────┘└─┘┴ ┴ ┴┴└──┘ └┘ ┴└─┘┴ ┴ └┘
typ └───────┘└─┘┴ ┴ ┴┴└──┘ └┘ ┴└─┘┴ ┴┴└┘
doc └───────┘ ┴ ┴ ┴ └──┘ └┘ ┴ ┴ └┘
txt └───────┘ ┴ ┴ ┴ └──┘ └┘ ┴ ┴ └┘
par └───────┘ ┴ ┴ ┴ └──┘ └┘ ┴ ┴ └┘
pid └───┘┴└─┘ ┴ ┴ ┴ └──┘ └┘ ┴ ┴ └┘
st ────────────────────────────────────────┘└─
319 have : 0 < δ,
id ┴ ┴
src └───────┘┴┴
typ └───────┘┴┴┴
doc └───────┘ ┴
txt └───────┘ ┴
par └───────┘ ┴
pid └───┘└──┘ ┴
st ─────────────┘└─
320 refine lt_min (sub_pos_of_lt (by rwa one_lt_exp_iff)) (sub_pos_of_lt _),
id └────┘ └────────────┘ └───────────┘
src └─────┘└────┘┴ ┴ ┴└──┘└────────────┘└─┘ └───────────┘└─┘
typ └─────┘└────┘┴ ┴ ┴└──┘└────────────┘└─┘ └───────────┘└─┘
doc └─────┘ ┴ ┴ ┴└──┘ └─┘ └─┘
txt └─────┘ ┴ ┴ ┴└──┘ └─┘ └─┘
par └─────┘ ┴ ┴ ┴└──┘ └─┘ └─┘
pid ┴ ┴ ┴ └───┘ └─┘ └─┘
st ───────────────────────────────────┘└─────────────────┘└──────────────────┘
321 by { rw exp_lt_one_iff, linarith },
id └────────────┘
src └─┘└────────────┘ └───────┘
typ └─┘└────────────┘ └───────┘
doc └─┘ └───────┘
txt └─┘ └───────┘
par └─┘ └───────┘
pid ┴ ┴
st ┴└────────────────┘└─────────┘└┘└
322 use [δ, this], assume x h,
id ┴ └──┘
src └───┘ └┘ ┴ └────────┘
typ └───┘┴└┘└──┘┴ └────────┘
doc └───┘ └┘ ┴ └────────┘
txt └───┘ └┘ ┴ └────────┘
par └───┘ └┘ ┴ └────────┘
pid └┘ └┘ ┴ └────────┘
st ──────────────┘└──────────┘└─
323 cases le_total 1 x with hx hx,
id └──────┘ ┴
src └────┘└──────┘└─┘ └─────────┘
typ └────┘└──────┘└─┘┴└─────────┘
doc └────┘ └─┘ └─────────┘
txt └────┘ └─┘ └─────────┘
par └────┘ └─┘ └─────────┘
pid ┴ └─┘ └─────────┘
st ──────────────────────────────┘└─
324 { have h : x < exp ε,
id ┴ └─┘ ┴
src └───────┘ ┴ ┴└─┘┴
typ └───────┘┴┴ ┴└─┘┴┴
doc └───────┘ ┴ ┴ ┴
txt └───────┘ ┴ ┴ ┴
par └───────┘ ┴ ┴ ┴
pid └────┘└─┘ ┴ ┴ ┴
st ───┘└────────────────┘└─
325 rw [dist_eq, abs_of_nonneg (sub_nonneg_of_le hx)] at h,
id └─────┘ └───────────┘ └──────────────┘ └┘
src └──┘└─────┘└┘└───────────┘┴ └──────────────┘┴ └─────┘
typ └──┘└─────┘└┘└───────────┘┴ └──────────────┘┴└┘└─────┘
doc └──┘ └┘ ┴ ┴ └─────┘
txt └──┘ └┘ ┴ ┴ └─────┘
par └──┘ └┘ ┴ ┴ └─────┘
pid └┘ └┘ ┴ ┴ └┘└───┘
st ────────────────┘└───────────────────────────────────┘┴└───┘└─
326 linarith [(min_le_left _ _ : δ ≤ exp ε - 1)],
id └─────────┘ ┴ ┴ └─┘ ┴
src └────────┘ └─────────┘└─────┘ ┴┴┴└─┘┴ ┴ └──┘
typ └────────┘ └─────────┘└─────┘┴┴┴┴└─┘┴┴┴ └──┘
doc └────────┘ └─────┘ ┴ ┴ ┴ ┴ └──┘
txt └────────┘ └─────┘ ┴ ┴ ┴ ┴ └──┘
par └────────┘ └─────┘ ┴ ┴ ┴ ┴ └──┘
pid ┴┴ └─────┘ ┴ ┴ ┴ ┴ └──┘
st ─────────────────────────────────────────────────┘└─
327 calc abs (log x - 0) = abs (log x) : by simp
id └──┘ └─┘ └─┘ ┴
src └──┘ └─┘ └─┘ └────
typ └──┘ └─┘ └─┘ ┴ └────
doc └──┘ └─┘ └────
txt └────
par └────
pid └
st ──────────────────────────────────────────┘└─────
328 ... = log x : abs_of_nonneg $ log_nonneg hx
id └───────────┘ └────────┘ └┘
src ─────┘ └───────────┘ └────────┘
typ ─────┘ └───────────┘ └────────┘ └┘
doc ─────┘
txt ─────┘
par ─────┘
pid ─────┘
st ─────┘└───────────────────────────────────────────
329 ... < ε : by { rwa [← exp_lt_exp, exp_log], linarith }},
id ┴ └────────┘ └─────┘
src └─────┘└────────┘└┘└─────┘┴ └───────┘
typ ┴ └─────┘└────────┘└┘└─────┘┴ └───────┘
doc └─────┘ └┘ ┴ └───────┘
txt └─────┘ └┘ ┴ └───────┘
par └─────┘ └┘ ┴ └───────┘
pid └──┘ └┘ ┴ ┴
st ─────────────────┘└──────────────────┘└───────┘┴└─────────┘└─┘└
330 { have h : exp (-ε) < x,
id └─┘ ┴ ┴
src └───────┘└─┘┴ └┘ ┴
typ └───────┘└─┘┴ ┴└┘ ┴┴
doc └───────┘ ┴ └┘ ┴
txt └───────┘ ┴ └┘ ┴
par └───────┘ ┴ └┘ ┴
pid └────┘└─┘ ┴ └┘ ┴
st ────────────────────────┘└─
331 rw [dist_eq, abs_of_nonpos (sub_nonpos_of_le hx)] at h,
id └─────┘ └───────────┘ └──────────────┘ └┘
src └──┘└─────┘└┘└───────────┘┴ └──────────────┘┴ └─────┘
typ └──┘└─────┘└┘└───────────┘┴ └──────────────┘┴└┘└─────┘
doc └──┘ └┘ ┴ ┴ └─────┘
txt └──┘ └┘ ┴ ┴ └─────┘
par └──┘ └┘ ┴ ┴ └─────┘
pid └┘ └┘ ┴ ┴ └┘└───┘
st ────────────────┘└───────────────────────────────────┘┴└───┘└─
332 linarith [(min_le_right _ _ : δ ≤ 1 - exp (-ε))],
id └──────────┘ ┴ └─┘ ┴
src └────────┘ └──────────┘└─────┘ ┴ └─┘ ┴└─┘┴ └─┘
typ └────────┘ └──────────┘└─────┘┴┴ └─┘ ┴└─┘┴ ┴└─┘
doc └────────┘ └─────┘ ┴ └─┘ ┴ ┴ └─┘
txt └────────┘ └─────┘ ┴ └─┘ ┴ ┴ └─┘
par └────────┘ └─────┘ ┴ └─┘ ┴ ┴ └─┘
pid ┴┴ └─────┘ ┴ └─┘ ┴ ┴ └─┘
st ─────────────────────────────────────────────────────┘└─
333 have : 0 < x := lt_trans (exp_pos _) h,
id ┴ └──────┘ └─────┘ ┴
src └───────┘ ┴ └──┘└──────┘┴ └─────┘└──┘
typ └───────┘ ┴┴└──┘└──────┘┴ └─────┘└──┘┴
doc └───────┘ ┴ └──┘ ┴ └──┘
txt └───────┘ ┴ └──┘ ┴ └──┘
par └───────┘ ┴ └──┘ ┴ └──┘
pid └───┘└──┘ ┴ └──┘ ┴ └──┘
st ─────────────────────────────────────────┘└─
334 calc abs (log x - 0) = abs (log x) : by simp
id └──┘ └─┘ └─┘ ┴
src └──┘ └─┘ └─┘ └────
typ └──┘ └─┘ └─┘ ┴ └────
doc └──┘ └─┘ └────
txt └────
par └────
pid └
st ──────────────────────────────────────────┘└─────
335 ... = -log x : abs_of_nonpos $ log_nonpos hx
id └───────────┘ └────────┘ └┘
src ─────┘ └───────────┘ └────────┘
typ ─────┘ └───────────┘ └────────┘ └┘
doc ─────┘
txt ─────┘
par ─────┘
pid ─────┘
st ─────┘└────────────────────────────────────────────
336 ... < ε : by { rw [neg_lt, ← exp_lt_exp, exp_log], assumption' } }
id ┴ └────┘ └────────┘ └─────┘
src └──┘└────┘└──┘└────────┘└┘└─────┘┴ └──────────┘
typ ┴ └──┘└────┘└──┘└────────┘└┘└─────┘┴ └──────────┘
doc └──┘ └──┘ └┘ ┴ └──────────┘
txt └──┘ └──┘ └┘ ┴ └──────────┘
par └──┘ └──┘ └┘ ┴ └──────────┘
pid └┘ └──┘ └┘ ┴ ┴
st ─────────────────┘└───────────┘└────────────┘└───────┘└─────────────┘└───
337 end
st ──┘
338
339 lemma continuous_log' : continuous (λx : {x:ℝ // 0 < x}, log x.val) :=
id └────────┘ ┴ ┴ ┴ ┴ └─┘ ┴└──┘
src └────────┘ ┴ ┴ ┴ └─┘ └──┘
typ └────────┘ ┴ ┴ ┴ ┴ └─┘ ┴└──┘
doc └────────┘ └─┘
340 continuous_iff_continuous_at.2 $ λ x,
id └──────────────────────────┘┴ ┴
src └──────────────────────────┘┴
typ └──────────────────────────┘┴ ┴
341 begin
st └─────
342 rw continuous_at,
id └───────────┘
src └─┘└───────────┘
typ └─┘└───────────┘
doc └─┘└───────────┘
txt └─┘
par └─┘
pid ┴
st ─────────────────┘└─
343 let f₁ := λ h:{h:ℝ // 0 < h}, log (x.1 * h.1),
id ┴ ┴ └─┘ ┴ ┴
src └────────┘ └─┘┴└┘ └────┘┴┴ └─┘└─┘┴ └─┘┴┴ └─┘
typ └────────┘ └─┘┴└┘ └────┘┴┴ └─┘└─┘┴ ┴└─┘┴┴ └─┘
doc └────────┘ └─┘ └┘ └────┘ ┴ └─┘└─┘┴ └─┘ ┴ └─┘
txt └────────┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ └─┘
par └────────┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ └─┘
pid └────┘┴└─┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ └─┘
st ──────────────────────────────────────────────┘└─
344 let f₂ := λ y:{y:ℝ // 0 < y}, subtype.mk (x.1 ⁻¹ * y.1) (mul_pos (inv_pos x.2) y.2),
id ┴ └────────┘ └┘ └─────┘ └─────┘ ┴
src └────────┘ └─┘┴└┘ └────┘ ┴ └─┘└────────┘┴ └─┘└┘┴ ┴ └──┘ └─────┘┴ └─────┘┴ └──┘ └─┘
typ └────────┘ └─┘┴└┘ └────┘ ┴ └─┘└────────┘┴ └─┘└┘┴ ┴ └──┘ └─────┘┴ └─────┘┴┴└──┘ └─┘
doc └────────┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └─┘
txt └────────┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └─┘
par └────────┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └─┘
pid └────┘┴└─┘ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └─┘
st ────────────────────────────────────────────────────────────────────────────────────┘└─
345 have H1 : tendsto f₁ (𝓝 ⟨1, zero_lt_one⟩) (𝓝 (log (x.1*1))),
id └─────┘ └┘ ┴ └─────────┘ └─┘ ┴
src └────────┘└─────┘┴ ┴ ┴┴ └─┘└─────────┘└─┘ ┴ └─┘┴ └┘ └──┘
typ └────────┘└─────┘┴└┘┴ ┴┴ └─┘└─────────┘└─┘ ┴ └─┘┴ ┴└┘ └──┘
doc └────────┘└─────┘┴ ┴ ┴┴ └─┘ └─┘ ┴ └─┘┴ └┘ └──┘
txt └────────┘ ┴ ┴ ┴ └─┘ └─┘ ┴ ┴ └┘ └──┘
par └────────┘ ┴ ┴ ┴ └─┘ └─┘ ┴ ┴ └┘ └──┘
pid └─────┘└─┘ ┴ ┴ ┴ └─┘ └─┘ ┴ ┴ └┘ └──┘
st ────────────────────────────────────────────────────────────┘└─
346 have : f₁ = λ h:{h:ℝ // 0 < h}, log x.1 + log h.1,
id └┘ ┴ ┴ ┴ ┴ └─┘
src └─────┘ ┴┴┴ └─┘┴└┘ └────┘ ┴ └─┘ ┴ └─┘┴┴└─┘┴ └┘
typ └─────┘└┘┴┴┴ └─┘┴└┘ └────┘ ┴ └─┘ ┴┴└─┘┴┴└─┘┴ └┘
doc └─────┘ ┴ ┴ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴└─┘┴ └┘
txt └─────┘ ┴ ┴ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
par └─────┘ ┴ ┴ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
pid └───┘└┘ ┴ ┴ └─┘ └┘ └────┘ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
st ────────────────────────────────────────────────────┘└─
347 ext h, rw ← log_mul x.2 h.2,
id └─────┘ ┴ ┴
src └───┘ └───┘└─────┘┴ └─┘ └┘
typ └───┘ └───┘└─────┘┴┴└─┘┴└┘
doc └───┘ └───┘ ┴ └─┘ └┘
txt └───┘ └───┘ ┴ └─┘ └┘
par └───┘ └───┘ ┴ └─┘ └┘
pid └┘ └─┘ ┴ └─┘ └┘
st ──────────┘└────────────────────┘└─
348 simp only [this, log_mul x.2 zero_lt_one, log_one],
id └──┘ └─────┘ ┴ └─────────┘ └─────┘
src └─────────┘ └┘└─────┘┴ └─┘└─────────┘└┘└─────┘┴
typ └─────────┘└──┘└┘└─────┘┴┴└─┘└─────────┘└┘└─────┘┴
doc └─────────┘ └┘ ┴ └─┘ └┘ ┴
txt └─────────┘ └┘ ┴ └─┘ └┘ ┴
par └─────────┘ └┘ ┴ └─┘ └┘ ┴
pid ┴└──┘└┘ └┘ ┴ └─┘ └┘ ┴
st ─────────────────────────────────────────────────────┘└─
349 exact tendsto_const_nhds.add (tendsto.comp tendsto_log_one_zero continuous_at_subtype_val),
id └────────────────────┘ └──────────┘ └──────────────────┘ └───────────────────────┘
src └────┘└────────────────────┘┴ └──────────┘┴└──────────────────┘┴└───────────────────────┘┴
typ └────┘└────────────────────┘┴ └──────────┘┴└──────────────────┘┴└───────────────────────┘┴
doc └────┘ ┴ ┴ ┴ ┴
txt └────┘ ┴ ┴ ┴ ┴
par └────┘ ┴ ┴ ┴ ┴
pid ┴ ┴ ┴ ┴ ┴
st ─────────────────────────────────────────────────────────────────────────────────────────────┘└─
350 have H2 : tendsto f₂ (𝓝 x) (𝓝 ⟨x.1⁻¹ * x.1, mul_pos (inv_pos x.2) x.2⟩),
id └─────┘ └┘ └─────┘ └─────┘ ┴
src └────────┘└─────┘┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘└─────┘┴ └─────┘┴ └──┘ └──┘
typ └────────┘└─────┘┴└┘┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘└─────┘┴ └─────┘┴ └──┘┴└──┘
doc └────────┘└─────┘┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └──┘
txt └────────┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └──┘
par └────────┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └──┘
pid └─────┘└─┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘ ┴ ┴ └──┘ └──┘
st ────────────────────────────────────────────────────────────────────────┘└─
351 rw tendsto_subtype_rng, exact tendsto_const_nhds.mul continuous_at_subtype_val,
id └─────────────────┘ └────────────────────┘ └───────────────────────┘
src └─┘└─────────────────┘ └────┘└────────────────────┘┴└───────────────────────┘
typ └─┘└─────────────────┘ └────┘└────────────────────┘┴└───────────────────────┘
doc └─┘ └────┘ ┴
txt └─┘ └────┘ ┴
par └─┘ └────┘ ┴
pid ┴ ┴ ┴
st ─────────────────────────┘└──────────────────────────────────────────────────────┘└─
352 suffices h : tendsto (f₁ ∘ f₂) (𝓝 x) (𝓝 (log x.1)),
id └─────┘ └┘ ┴ └┘ └─┘ ┴
src └───────────┘└─────┘┴ ┴┴┴ └┘ ┴ └┘ ┴ └─┘┴ └──┘
typ └───────────┘└─────┘┴ └┘┴┴┴└┘└┘ ┴ └┘ ┴ └─┘┴┴└──┘
doc └───────────┘└─────┘┴ ┴ ┴ └┘ ┴ └┘ ┴ └─┘┴ └──┘
txt └───────────┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘
par └───────────┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘
pid └────────┘└─┘ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └──┘
st ───────────────────────────────────────────────────┘└─
353 begin
st ──────┘└
354 convert h, ext y,
id ┴
src └──────┘ └───┘
typ └──────┘┴ └───┘
doc └──────┘ └───┘
txt └──────┘ └───┘
par └──────┘ └───┘
pid ┴ └┘
st ────────────┘└─────┘└─
355 have : x.val * (x.val⁻¹ * y.val) = y.val,
id └───┘ └───┘
src └─────┘ ┴ ┴ └───┘ ┴ ┴ └┘ ┴└───┘
typ └─────┘ ┴ ┴ └───┘ ┴ ┴ └┘ ┴└───┘
doc └─────┘ ┴ ┴ ┴ ┴ └┘ ┴
txt └─────┘ ┴ ┴ ┴ ┴ └┘ ┴
par └─────┘ ┴ ┴ ┴ ┴ └┘ ┴
pid └───┘└┘ ┴ ┴ ┴ ┴ └┘ ┴
st ───────────────────────────────────────────┘└─
356 rw [← mul_assoc, mul_inv_cancel (ne_of_gt x.2), one_mul],
id └───────┘ └────────────┘ └──────┘ ┴ └─────┘
src └────┘└───────┘└┘└────────────┘┴ └──────┘┴ └───┘└─────┘┴
typ └────┘└───────┘└┘└────────────┘┴ └──────┘┴┴└───┘└─────┘┴
doc └────┘ └┘ ┴ ┴ └───┘ ┴
txt └────┘ └┘ ┴ ┴ └───┘ ┴
par └────┘ └┘ ┴ ┴ └───┘ ┴
pid └──┘ └┘ ┴ ┴ └───┘ ┴
st ────────────────────┘└─────────────────────────────┘└───────┘└──
357 show log (y.val) = log (x.val * (x.val⁻¹ * y.val)), rw this
id └─┘ └───┘ └───┘ └──┘
src └───┘ ┴ └┘ ┴└─┘┴ ┴ ┴ └───┘ ┴ ┴└───┘└┘ └─┘ └
typ └───┘ ┴ └┘ ┴└─┘┴ ┴ ┴ └───┘ ┴ ┴└───┘└┘ └─┘└──┘└
doc └───┘ ┴ └┘ ┴└─┘┴ ┴ ┴ ┴ ┴ └┘ └─┘ └
txt └───┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ └─┘ └
par └───┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ └─┘ └
pid └───┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ └
st ─────────────────────────────────────────────────────┘└─────────
358 end,
src ─┘
typ ─┘
doc ─┘
txt ─┘
par ─┘
pid ─┘
st ─┘└─┘└─
359 exact tendsto.comp (by rwa mul_one at H1)
id └──────────┘ └─────┘
src └────┘└──────────┘┴ ┴└──┘└─────┘└────┘└─
typ └────┘└──────────┘┴ ┴└──┘└─────┘└────┘└─
doc └────┘ ┴ ┴└──┘ └────┘└─
txt └────┘ ┴ ┴└──┘ └────┘└─
par └────┘ ┴ ┴└──┘ └────┘└─
pid ┴ ┴ └───┘ └───────
st ───────────────────────┘└────────────────┘└─
360 (by { simp only [inv_mul_cancel (ne_of_gt x.2)] at H2, assumption })
id └────────────┘ └──────┘ ┴
src ───┘ └─┘└─────────┘└────────────┘┴ └──────┘┴ └────────┘└┘└─────────┘└─┘
typ ───┘ └─┘└─────────┘└────────────┘┴ └──────┘┴┴└────────┘└┘└─────────┘└─┘
doc ───┘ └─┘└─────────┘ ┴ ┴ └────────┘└┘└─────────┘└─┘
txt ───┘ └─┘└─────────┘ ┴ ┴ └────────┘└┘└─────────┘└─┘
par ───┘ └─┘└─────────┘ ┴ ┴ └────────┘└┘└─────────┘└─┘
pid ───┘ └────────────┘ ┴ ┴ └───────────────────────┘┴
st ──────┘└────────────────────────────────────────────────┘└───────────┘┴└┘
361 end
st └─┘
362
363 lemma continuous_at_log (hx : 0 < x) : continuous_at log x :=
id ┴ ┴ └───────────┘ └─┘ ┴
src ┴ └───────────┘ └─┘
typ ┴ ┴ └───────────┘ └─┘ ┴
doc └───────────┘ └─┘
364 continuous_within_at.continuous_at (continuous_on_iff_continuous_restrict.2 continuous_log' _ hx)
id └────────────────────────────────┘ └───────────────────────────────────┘┴ └─────────────┘ └┘
src └────────────────────────────────┘ └───────────────────────────────────┘┴ └─────────────┘
typ └────────────────────────────────┘ └───────────────────────────────────┘┴ └─────────────┘ └┘
365 (mem_nhds_sets (is_open_lt' _) hx)
id └───────────┘ └─────────┘ └┘
src └───────────┘ └─────────┘
typ └───────────┘ └─────────┘ └┘
366
367 /--
368 Three forms of the continuity of `real.log` is provided.
369 For the other two forms, see `real.continuous_log'` and `real.continuous_at_log`
370 -/
371 lemma continuous_log {α : Type*} [topological_space α] {f : α → ℝ} (h : ∀a, 0 < f a)
id └───────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └───────────────┘ ┴ ┴
typ └───────────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───────────────┘
372 (hf : continuous f) : continuous (λa, log (f a)) :=
id └────────┘ ┴ └────────┘ ┴ └─┘ ┴ ┴
src └────────┘ └────────┘ └─┘
typ └────────┘ ┴ └────────┘ ┴ └─┘ ┴ ┴
doc └────────┘ └────────┘ └─┘
373 show continuous ((log ∘ @subtype.val ℝ (λr, 0 < r)) ∘ λa, ⟨f a, h a⟩),
id └────────┘ └─┘ ┴ └─────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src └────────┘ └─┘ ┴ └─────────┘ ┴ ┴ ┴
typ └────────┘ └─┘ ┴ └─────────┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └────────┘ └─┘
374 from continuous_log'.comp (continuous_subtype_mk _ hf)
id └─────────────┘└───┘ └───────────────────┘ └┘
src └─────────────┘└───┘ └───────────────────┘
typ └─────────────┘└───┘ └───────────────────┘ └┘
375
376 end prove_log_is_continuous
377
378 lemma exists_cos_eq_zero : 0 ∈ cos '' set.Icc (1:ℝ) 2 :=
id ┴ └─┘ └┘ └─────┘ ┴
src ┴ └─┘ └┘ └─────┘ ┴
typ ┴ └─┘ └┘ └─────┘ ┴
doc └─────┘
379 intermediate_value_Icc' (by norm_num) continuous_cos.continuous_on
id └─────────────────────┘ └────────────┘└────────────┘
src └─────────────────────┘ └──────┘ └────────────┘└────────────┘
typ └─────────────────────┘ └──────┘ └────────────┘└────────────┘
doc └─────────────────────┘ └──────┘
txt └──────┘
par └──────┘
st └───────┘
380 ⟨le_of_lt cos_two_neg, le_of_lt cos_one_pos⟩
id └──────┘ └─────────┘ └──────┘ └─────────┘
src └──────┘ └─────────┘ └──────┘ └─────────┘
typ └──────┘ └─────────┘ └──────┘ └─────────┘
381
382 /-- The number π = 3.14159265... Defined here using choice as twice a zero of cos in [1,2], from
383 which one can derive all its properties. For explicit bounds on π, see `data.real.pi`. -/
384 noncomputable def pi : ℝ := 2 * classical.some exists_cos_eq_zero
id ┴ ┴ └────────────┘ └────────────────┘
src ┴ ┴ └────────────┘ └────────────────┘
typ ┴ ┴ └────────────┘ └────────────────┘
385
386 localized "notation `π` := real.pi" in real
387
388 @[simp] lemma cos_pi_div_two : cos (π / 2) = 0 :=
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └──┘ ┴
389 by rw [pi, mul_div_cancel_left _ (@two_ne_zero' ℝ _ _ _)];
id └┘ └─────────────────┘ └──────────┘
src └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
typ └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
doc └──┘└┘└┘ └─┘ ┴ └──────┘
txt └──┘ └┘ └─┘ ┴ └──────┘
par └──┘ └┘ └─┘ ┴ └──────┘
pid └┘ └┘ └─┘ ┴ └──────┘
st └─────┘└─────────────────────────────────────────────┘┴└─
390 exact (classical.some_spec exists_cos_eq_zero).2
id └─────────────────┘ └────────────────┘
src └────┘ └─────────────────┘┴└────────────────┘└───
typ └────┘ └─────────────────┘┴└────────────────┘└───
doc └────┘ ┴ └───
txt └────┘ ┴ └───
par └────┘ ┴ └───
pid ┴ ┴ ┴└──
st ───────────────────────────────────────────────────
391
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
392 lemma one_le_pi_div_two : (1 : ℝ) ≤ π / 2 :=
id ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴
393 by rw [pi, mul_div_cancel_left _ (@two_ne_zero' ℝ _ _ _)];
id └┘ └─────────────────┘ └──────────┘
src └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
typ └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
doc └──┘└┘└┘ └─┘ ┴ └──────┘
txt └──┘ └┘ └─┘ ┴ └──────┘
par └──┘ └┘ └─┘ ┴ └──────┘
pid └┘ └┘ └─┘ ┴ └──────┘
st └─────┘└─────────────────────────────────────────────┘┴└─
394 exact (classical.some_spec exists_cos_eq_zero).1.1
id └─────────────────┘ └────────────────┘
src └────┘ └─────────────────┘┴└────────────────┘└─────
typ └────┘ └─────────────────┘┴└────────────────┘└─────
doc └────┘ ┴ └─────
txt └────┘ ┴ └─────
par └────┘ ┴ └─────
pid ┴ ┴ └─┘└──
st ─────────────────────────────────────────────────────
395
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
396 lemma pi_div_two_le_two : π / 2 ≤ 2 :=
id ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴
doc ┴
397 by rw [pi, mul_div_cancel_left _ (@two_ne_zero' ℝ _ _ _)];
id └┘ └─────────────────┘ └──────────┘
src └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
typ └──┘└┘└┘└─────────────────┘└─┘ └──────────┘┴ └──────┘
doc └──┘└┘└┘ └─┘ ┴ └──────┘
txt └──┘ └┘ └─┘ ┴ └──────┘
par └──┘ └┘ └─┘ ┴ └──────┘
pid └┘ └┘ └─┘ ┴ └──────┘
st └─────┘└─────────────────────────────────────────────┘┴└─
398 exact (classical.some_spec exists_cos_eq_zero).1.2
id └─────────────────┘ └────────────────┘
src └────┘ └─────────────────┘┴└────────────────┘└─────
typ └────┘ └─────────────────┘┴└────────────────┘└─────
doc └────┘ ┴ └─────
txt └────┘ ┴ └─────
par └────┘ ┴ └─────
pid ┴ ┴ └─┘└──
st ─────────────────────────────────────────────────────
399
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
400 lemma two_le_pi : (2 : ℝ) ≤ π :=
id ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴
doc ┴
401 (div_le_div_right (show (0 : ℝ) < 2, by norm_num)).1
id └──────────────┘ ┴ ┴ ┴
src └──────────────┘ ┴ ┴ └──────┘ ┴
typ └──────────────┘ ┴ ┴ └──────┘ ┴
doc └──────┘
txt └──────┘
par └──────┘
st └───────┘
402 (by rw div_self (@two_ne_zero' ℝ _ _ _); exact one_le_pi_div_two)
id └──────┘ └──────────┘ └───────────────┘
src └─┘└──────┘┴ └──────────┘┴ └─────┘ └────┘└───────────────┘
typ └─┘└──────┘┴ └──────────┘┴ └─────┘ └────┘└───────────────┘
doc └─┘ ┴ ┴ └─────┘ └────┘
txt └─┘ ┴ ┴ └─────┘ └────┘
par └─┘ ┴ ┴ └─────┘ └────┘
pid ┴ ┴ ┴ └─────┘ ┴
st └───────────────────────────────────────────────────────────┘
403
404 lemma pi_le_four : π ≤ 4 :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
doc ┴
405 (div_le_div_right (show (0 : ℝ) < 2, by norm_num)).1
id └──────────────┘ ┴ ┴ ┴
src └──────────────┘ ┴ ┴ └──────┘ ┴
typ └──────────────┘ ┴ ┴ └──────┘ ┴
doc └──────┘
txt └──────┘
par └──────┘
st └───────┘
406 (calc π / 2 ≤ 2 : pi_div_two_le_two
id ┴ ┴ └───────────────┘
src ┴ ┴ └───────────────┘
typ ┴ ┴ └───────────────┘
doc ┴
407 ... = 4 / 2 : by norm_num)
id ┴
src ┴ └──────┘
typ ┴ └──────┘
doc └──────┘
txt └──────┘
par └──────┘
st └───────┘
408
409 lemma pi_pos : 0 < π :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
doc ┴
410 lt_of_lt_of_le (by norm_num) two_le_pi
id └────────────┘ └───────┘
src └────────────┘ └──────┘ └───────┘
typ └────────────┘ └──────┘ └───────┘
doc └──────┘
txt └──────┘
par └──────┘
st └───────┘
411
412 lemma pi_div_two_pos : 0 < π / 2 :=
id ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴
doc ┴
413 half_pos pi_pos
id └──────┘ └────┘
src └──────┘ └────┘
typ └──────┘ └────┘
414
415 lemma two_pi_pos : 0 < 2 * π :=
id ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴
doc ┴
416 by linarith [pi_pos]
id └────┘
src └────────┘└────┘└─
typ └────────┘└────┘└─
doc └────────┘ └─
txt └────────┘ └─
par └────────┘ └─
pid ┴┴ ┴└
st └──────────────────
417
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
418 @[simp] lemma sin_pi : sin π = 0 :=
id └─┘ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴
doc └──┘ ┴
419 by rw [← mul_div_cancel_left pi (@two_ne_zero ℝ _), two_mul, add_div,
id └─────────────────┘ └┘ └─────────┘ └─────┘ └─────┘
src └────┘└─────────────────┘┴└┘┴ └─────────┘┴ └───┘└─────┘└┘└─────┘└─
typ └────┘└─────────────────┘┴└┘┴ └─────────┘┴ └───┘└─────┘└┘└─────┘└─
doc └────┘ ┴└┘┴ ┴ └───┘ └┘ └─
txt └────┘ ┴ ┴ ┴ └───┘ └┘ └─
par └────┘ ┴ ┴ ┴ └───┘ └┘ └─
pid └──┘ ┴ ┴ ┴ └───┘ └┘ └─
st └──────────────────────────────────────────────┘└───────┘└───────┘└─
420 sin_add, cos_pi_div_two]; simp
id └─────┘ └────────────┘
src ───┘└─────┘└┘└────────────┘┴ └────
typ ───┘└─────┘└┘└────────────┘┴ └────
doc ───┘ └┘ ┴ └────
txt ───┘ └┘ ┴ └────
par ───┘ └┘ ┴ └────
pid ───┘ └┘ ┴ └
st ──────────┘└──────────────┘┴└──────
421
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
422 @[simp] lemma cos_pi : cos π = -1 :=
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └──┘ ┴
st └┘
423 by rw [← mul_div_cancel_left pi (@two_ne_zero ℝ _), mul_div_assoc,
id └─────────────────┘ └┘ └─────────┘ └───────────┘
src └────┘└─────────────────┘┴└┘┴ └─────────┘┴ └───┘└───────────┘└─
typ └────┘└─────────────────┘┴└┘┴ └─────────┘┴ └───┘└───────────┘└─
doc └────┘ ┴└┘┴ ┴ └───┘ └─
txt └────┘ ┴ ┴ ┴ └───┘ └─
par └────┘ ┴ ┴ ┴ └───┘ └─
pid └──┘ ┴ ┴ ┴ └───┘ └─
st └──────────────────────────────────────────────┘└─────────────┘└─
424 cos_two_mul, cos_pi_div_two];
id └─────────┘ └────────────┘
src ───┘└─────────┘└┘└────────────┘┴
typ ───┘└─────────┘└┘└────────────┘┴
doc ───┘ └┘ ┴
txt ───┘ └┘ ┴
par ───┘ └┘ ┴
pid ───┘ └┘ ┴
st ──────────────┘└──────────────┘┴└─
425 simp [bit0, pow_add]
id └──┘ └─────┘
src └────┘└──┘└┘└─────┘└─
typ └────┘└──┘└┘└─────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st ───────────────────────
426
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
427 @[simp] lemma sin_two_pi : sin (2 * π) = 0 :=
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └──┘ ┴
428 by simp [two_mul, sin_add]
id └─────┘ └─────┘
src └────┘└─────┘└┘└─────┘└─
typ └────┘└─────┘└┘└─────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └────────────────────────
429
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
430 @[simp] lemma cos_two_pi : cos (2 * π) = 1 :=
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └──┘ ┴
431 by simp [two_mul, cos_add]
id └─────┘ └─────┘
src └────┘└─────┘└┘└─────┘└─
typ └────┘└─────┘└┘└─────┘└─
doc └────┘ └┘ └─
txt └────┘ └┘ └─
par └────┘ └┘ └─
pid ┴┴ └┘ ┴└
st └────────────────────────
432
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
433 lemma sin_add_pi (x : ℝ) : sin (x + π) = -sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴└─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
doc ┴
434 by simp [sin_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
435
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
436 lemma sin_add_two_pi (x : ℝ) : sin (x + 2 * π) = sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
437 by simp [sin_add_pi, sin_add, sin_two_pi, cos_two_pi]
id └────────┘ └─────┘ └────────┘ └────────┘
src └────┘└────────┘└┘└─────┘└┘└────────┘└┘└────────┘└─
typ └────┘└────────┘└┘└─────┘└┘└────────┘└┘└────────┘└─
doc └────┘ └┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └┘ └─
par └────┘ └┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ └┘ ┴└
st └───────────────────────────────────────────────────
438
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
439 lemma cos_add_two_pi (x : ℝ) : cos (x + 2 * π) = cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
440 by simp [cos_add, cos_two_pi, sin_two_pi]
id └─────┘ └────────┘ └────────┘
src └────┘└─────┘└┘└────────┘└┘└────────┘└─
typ └────┘└─────┘└┘└────────┘└┘└────────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ ┴└
st └───────────────────────────────────────
441
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
442 lemma sin_pi_sub (x : ℝ) : sin (π - x) = sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
443 by simp [sin_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
444
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
445 lemma cos_add_pi (x : ℝ) : cos (x + π) = -cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴└─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
doc ┴
446 by simp [cos_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
447
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
448 lemma cos_pi_sub (x : ℝ) : cos (π - x) = -cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴└─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘ ┴
doc ┴
449 by simp [cos_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
450
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
451 lemma sin_pos_of_pos_of_lt_pi {x : ℝ} (h0x : 0 < x) (hxp : x < π) : 0 < sin x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
452 if hx2 : x ≤ 2 then sin_pos_of_pos_of_le_two h0x hx2
id └┘ ┴ ┴ └──────────────────────┘ └─┘ └─┘
src └┘ ┴ └──────────────────────┘
typ └┘ ┴ ┴ └──────────────────────┘ └─┘ └─┘
453 else
454 have (2 : ℝ) + 2 = 4, from rfl,
id └──┘ ┴ ┴ ┴ └─┘
src ┴ ┴ ┴ └─┘
typ └──┘ ┴ ┴ ┴ └─┘
455 have π - x ≤ 2, from sub_le_iff_le_add.2
id ┴ ┴ ┴ ┴ └───────────────┘┴
src ┴ ┴ ┴ └───────────────┘┴
typ ┴ ┴ ┴ ┴ └───────────────┘┴
doc ┴
456 (le_trans pi_le_four (this ▸ add_le_add_left (le_of_not_ge hx2) _)),
id └──────┘ └────────┘ └──┘ ┴ └─────────────┘ └──────────┘ └─┘
src └──────┘ └────────┘ ┴ └─────────────┘ └──────────┘
typ └──────┘ └────────┘ └──┘ ┴ └─────────────┘ └──────────┘ └─┘
457 sin_pi_sub x ▸ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this
id └────────┘ ┴ ┴ └──────────────────────┘ └─────┘┴ └─┘ └──┘
src └────────┘ ┴ └──────────────────────┘ └─────┘┴
typ └────────┘ ┴ ┴ └──────────────────────┘ └─────┘┴ └─┘ └──┘
458
459 lemma sin_nonneg_of_nonneg_of_le_pi {x : ℝ} (h0x : 0 ≤ x) (hxp : x ≤ π) : 0 ≤ sin x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
460 match lt_or_eq_of_le h0x with
id └────────────┘ └─┘
src └────────────┘
typ └────────────┘ └─┘
461 | or.inl h0x := (lt_or_eq_of_le hxp).elim
id └────┘ └─┘ └────────────┘ └─┘ └──┘
src └────┘ └────────────┘ └──┘
typ └────┘ └─┘ └────────────┘ └─┘ └──┘
462 (le_of_lt ∘ sin_pos_of_pos_of_lt_pi h0x)
id └──────┘ ┴ └─────────────────────┘
src └──────┘ ┴ └─────────────────────┘
typ └──────┘ ┴ └─────────────────────┘
463 (λ hpx, by simp [hpx])
id └─┘ └─┘
src └────┘ ┴
typ └─┘ └────┘└─┘┴
doc └────┘ ┴
txt └────┘ ┴
par └────┘ ┴
pid ┴┴ ┴
st └─────────┘
464 | or.inr h0x := by simp [h0x.symm]
id └────┘
src └────┘ └────┘ └┘
typ └────┘ └────┘└──────┘└┘
doc └────┘ └┘
txt └────┘ └┘
par └────┘ └┘
pid ┴┴ ┴┴
st └───────────────┘
465 end
466
467 lemma sin_neg_of_neg_of_neg_pi_lt {x : ℝ} (hx0 : x < 0) (hpx : -π < x) : sin x < 0 :=
id ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴ ┴
src ┴ ┴ ┴┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴ ┴
doc ┴
468 neg_pos.1 $ sin_neg x ▸ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx)
id └─────┘┴ └─────┘ ┴ ┴ └─────────────────────┘ └─────┘┴ └─┘ └────┘┴ └─┘
src └─────┘┴ └─────┘ ┴ └─────────────────────┘ └─────┘┴ └────┘┴
typ └─────┘┴ └─────┘ ┴ ┴ └─────────────────────┘ └─────┘┴ └─┘ └────┘┴ └─┘
469
470 lemma sin_nonpos_of_nonnpos_of_neg_pi_le {x : ℝ} (hx0 : x ≤ 0) (hpx : -π ≤ x) : sin x ≤ 0 :=
id ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴ ┴
src ┴ ┴ ┴┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴┴ ┴ ┴ └─┘ ┴ ┴
doc ┴
471 neg_nonneg.1 $ sin_neg x ▸ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx)
id └────────┘┴ └─────┘ ┴ ┴ └───────────────────────────┘ └────────┘┴ └─┘ └────┘┴ └─┘
src └────────┘┴ └─────┘ ┴ └───────────────────────────┘ └────────┘┴ └────┘┴
typ └────────┘┴ └─────┘ ┴ ┴ └───────────────────────────┘ └────────┘┴ └─┘ └────┘┴ └─┘
472
473 @[simp] lemma sin_pi_div_two : sin (π / 2) = 1 :=
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └──┘ ┴
474 have sin (π / 2) = 1 ∨ sin (π / 2) = -1 :=
id └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
doc ┴ ┴
475 by simpa [pow_two, mul_self_eq_one_iff] using sin_sq_add_cos_sq (π / 2),
id └─────┘ └─────────────────┘ └───────────────┘ ┴
src └─────┘└─────┘└┘└─────────────────┘└──────┘└───────────────┘┴ ┴┴└─┘
typ └─────┘└─────┘└┘└─────────────────┘└──────┘└───────────────┘┴ ┴┴└─┘
doc └─────┘ └┘ └──────┘ ┴ ┴ └─┘
txt └─────┘ └┘ └──────┘ ┴ ┴ └─┘
par └─────┘ └┘ └──────┘ ┴ ┴ └─┘
pid ┴┴ └┘ ┴┴└────┘ ┴ ┴ └─┘
st └───────────────────────────────────────────────────────────────────┘
476 this.resolve_right
id └──┘└────────────┘
src └────────────┘
typ └──┘└────────────┘
477 (λ h, (show ¬(0 : ℝ) < -1, by norm_num) $
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ └──────┘
typ ┴ ┴ ┴ ┴ ┴ └──────┘
doc └──────┘
txt └──────┘
par └──────┘
st └───────┘
478 h ▸ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos))
id ┴ ┴ └─────────────────────┘ └────────────┘ └──────────┘ └────┘
src ┴ └─────────────────────┘ └────────────┘ └──────────┘ └────┘
typ ┴ ┴ └─────────────────────┘ └────────────┘ └──────────┘ └────┘
479
480 lemma sin_add_pi_div_two (x : ℝ) : sin (x + π / 2) = cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
481 by simp [sin_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
482
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
483 lemma sin_sub_pi_div_two (x : ℝ) : sin (x - π / 2) = -cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└─┘ ┴
doc ┴
484 by simp [sin_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
485
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
486 lemma sin_pi_div_two_sub (x : ℝ) : sin (π / 2 - x) = cos x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
487 by simp [sin_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
488
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
489 lemma cos_add_pi_div_two (x : ℝ) : cos (x + π / 2) = -sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ ┴└─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴└─┘ ┴
doc ┴
490 by simp [cos_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
491
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
492 lemma cos_sub_pi_div_two (x : ℝ) : cos (x - π / 2) = sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
493 by simp [cos_add]
id └─────┘
src └────┘└─────┘└─
typ └────┘└─────┘└─
doc └────┘ └─
txt └────┘ └─
par └────┘ └─
pid ┴┴ ┴└
st └───────────────
494
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
495 lemma cos_pi_div_two_sub (x : ℝ) : cos (π / 2 - x) = sin x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ └─┘
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴
496 by rw [← cos_neg, neg_sub, cos_sub_pi_div_two]
id └─────┘ └─────┘ └────────────────┘
src └────┘└─────┘└┘└─────┘└┘└────────────────┘└─
typ └────┘└─────┘└┘└─────┘└┘└────────────────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid └──┘ └┘ └┘ ┴└
st └────────────┘└───────┘└──────────────────┘┴└
497
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
498 lemma cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two
499 {x : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2) : 0 < cos x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴ ┴
500 sin_add_pi_div_two x ▸ sin_pos_of_pos_of_lt_pi (by linarith) (by linarith)
id └────────────────┘ ┴ ┴ └─────────────────────┘
src └────────────────┘ ┴ └─────────────────────┘ └──────┘ └──────┘
typ └────────────────┘ ┴ ┴ └─────────────────────┘ └──────┘ └──────┘
doc └──────┘ └──────┘
txt └──────┘ └──────┘
par └──────┘ └──────┘
st └───────┘ └───────┘
501
502 lemma cos_nonneg_of_neg_pi_div_two_le_of_le_pi_div_two
503 {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : 0 ≤ cos x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
doc ┴ ┴
504 match lt_or_eq_of_le hx₁, lt_or_eq_of_le hx₂ with
id └────────────┘ └─┘ └────────────┘ └─┘
src └────────────┘ └────────────┘
typ └────────────┘ └─┘ └────────────┘ └─┘
505 | or.inl hx₁, or.inl hx₂ := le_of_lt (cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two hx₁ hx₂)
id └─┘ └────┘ └─┘ └──────┘ └───────────────────────────────────────────┘
src └────┘ └──────┘ └───────────────────────────────────────────┘
typ └─┘ └────┘ └─┘ └──────┘ └───────────────────────────────────────────┘
506 | or.inl hx₁, or.inr hx₂ := by simp [hx₂]
id └────┘ └────┘ └─┘
src └────┘ └────┘ └────┘ └┘
typ └────┘ └────┘ └────┘└─┘└┘
doc └────┘ └┘
txt └────┘ └┘
par └────┘ └┘
pid ┴┴ ┴┴
st └──────────┘
507 | or.inr hx₁, _ := by simp [hx₁.symm]
id └────┘
src └────┘ └────┘ └┘
typ └────┘ └────┘└──────┘└┘
doc └────┘ └┘
txt └────┘ └┘
par └────┘ └┘
pid ┴┴ ┴┴
st └───────────────┘
508 end
509
510 lemma cos_neg_of_pi_div_two_lt_of_lt {x : ℝ} (hx₁ : π / 2 < x) (hx₂ : x < π + π / 2) : cos x < 0 :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
doc ┴ ┴ ┴
511 neg_pos.1 $ cos_pi_sub x ▸
id └─────┘┴ └────────┘ ┴ ┴
src └─────┘┴ └────────┘ ┴
typ └─────┘┴ └────────┘ ┴ ┴
512 cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two (by linarith) (by linarith)
id └───────────────────────────────────────────┘
src └───────────────────────────────────────────┘ └──────┘ └──────┘
typ └───────────────────────────────────────────┘ └──────┘ └──────┘
doc └──────┘ └──────┘
txt └──────┘ └──────┘
par └──────┘ └──────┘
st └───────┘ └───────┘
513
514 lemma cos_nonpos_of_pi_div_two_le_of_le {x : ℝ} (hx₁ : π / 2 ≤ x) (hx₂ : x ≤ π + π / 2) : cos x ≤ 0 :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴
doc ┴ ┴ ┴
515 neg_nonneg.1 $ cos_pi_sub x ▸
id └────────┘┴ └────────┘ ┴ ┴
src └────────┘┴ └────────┘ ┴
typ └────────┘┴ └────────┘ ┴ ┴
516 cos_nonneg_of_neg_pi_div_two_le_of_le_pi_div_two (by linarith) (by linarith)
id └──────────────────────────────────────────────┘
src └──────────────────────────────────────────────┘ └──────┘ └──────┘
typ └──────────────────────────────────────────────┘ └──────┘ └──────┘
doc └──────┘ └──────┘
txt └──────┘ └──────┘
par └──────┘ └──────┘
st └───────┘ └───────┘
517
518 lemma sin_nat_mul_pi (n : ℕ) : sin (n * π) = 0 :=
id ┴ └─┘ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴
doc ┴
519 by induction n; simp [add_mul, sin_add, *]
id ┴ └─────┘ └─────┘
src └────────┘ └────┘└─────┘└┘└─────┘└────
typ └────────┘┴ └────┘└─────┘└┘└─────┘└────
doc └────────┘ └────┘ └┘ └────
txt └────────┘ └────┘ └┘ └────
par └────────┘ └────┘ └┘ └────
pid ┴ ┴┴ └┘ └──┘└
st └────────────────────────────────────────
520
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
521 lemma sin_int_mul_pi (n : ℤ) : sin (n * π) = 0 :=
id ┴ └─┘ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴
doc ┴
522 by cases n; simp [add_mul, sin_add, *, sin_nat_mul_pi]
id ┴ └─────┘ └─────┘ └────────────┘
src └────┘ └────┘└─────┘└┘└─────┘└───┘└────────────┘└─
typ └────┘┴ └────┘└─────┘└┘└─────┘└───┘└────────────┘└─
doc └────┘ └────┘ └┘ └───┘ └─
txt └────┘ └────┘ └┘ └───┘ └─
par └────┘ └────┘ └┘ └───┘ └─
pid ┴ ┴┴ └┘ └───┘ ┴└
st └────────────────────────────────────────────────────
523
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
524 lemma cos_nat_mul_two_pi (n : ℕ) : cos (n * (2 * π)) = 1 :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc ┴
525 by induction n; simp [*, mul_add, cos_add, add_mul, cos_two_pi, sin_two_pi]
id ┴ └─────┘ └─────┘ └─────┘ └────────┘ └────────┘
src └────────┘ └───────┘└─────┘└┘└─────┘└┘└─────┘└┘└────────┘└┘└────────┘└─
typ └────────┘┴ └───────┘└─────┘└┘└─────┘└┘└─────┘└┘└────────┘└┘└────────┘└─
doc └────────┘ └───────┘ └┘ └┘ └┘ └┘ └─
txt └────────┘ └───────┘ └┘ └┘ └┘ └┘ └─
par └────────┘ └───────┘ └┘ └┘ └┘ └┘ └─
pid ┴ ┴└──┘ └┘ └┘ └┘ └┘ ┴└
st └─────────────────────────────────────────────────────────────────────────
526
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
527 lemma cos_int_mul_two_pi (n : ℤ) : cos (n * (2 * π)) = 1 :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc ┴
528 by cases n; simp only [cos_nat_mul_two_pi, int.of_nat_eq_coe,
id ┴ └────────────────┘ └───────────────┘
src └────┘ └─────────┘└────────────────┘└┘└───────────────┘└─
typ └────┘┴ └─────────┘└────────────────┘└┘└───────────────┘└─
doc └────┘ └─────────┘ └┘ └─
txt └────┘ └─────────┘ └┘ └─
par └────┘ └─────────┘ └┘ └─
pid ┴ ┴└──┘└┘ └┘ └─
st └───────────────────────────────────────────────────────────
529 int.neg_succ_of_nat_coe, int.cast_coe_nat, int.cast_neg,
id └─────────────────────┘ └──────────────┘ └──────────┘
src ─┘└─────────────────────┘└┘└──────────────┘└┘└──────────┘└─
typ ─┘└─────────────────────┘└┘└──────────────┘└┘└──────────┘└─
doc ─┘ └┘ └┘ └─
txt ─┘ └┘ └┘ └─
par ─┘ └┘ └┘ └─
pid ─┘ └┘ └┘ └─
st ───────────────────────────────────────────────────────────
530 (neg_mul_eq_neg_mul _ _).symm, cos_neg]
id └────────────────┘ └─────┘
src ─┘ └────────────────┘└──────────┘└─────┘└─
typ ─┘ └────────────────┘└──────────┘└─────┘└─
doc ─┘ └──────────┘ └─
txt ─┘ └──────────┘ └─
par ─┘ └──────────┘ └─
pid ─┘ └──────────┘ ┴└
st ──────────────────────────────────────────
531
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
532 lemma cos_int_mul_two_pi_add_pi (n : ℤ) : cos (n * (2 * π) + π) = -1 :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
533 by simp [cos_add, sin_add, cos_int_mul_two_pi]
id └─────┘ └─────┘ └────────────────┘
src └────┘└─────┘└┘└─────┘└┘└────────────────┘└─
typ └────┘└─────┘└┘└─────┘└┘└────────────────┘└─
doc └────┘ └┘ └┘ └─
txt └────┘ └┘ └┘ └─
par └────┘ └┘ └┘ └─
pid ┴┴ └┘ └┘ ┴└
st └────────────────────────────────────────────
534
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
535 lemma sin_eq_zero_iff_of_lt_of_lt {x : ℝ} (hx₁ : -π < x) (hx₂ : x < π) :
id ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴┴ ┴ ┴ ┴
typ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
536 sin x = 0 ↔ x = 0 :=
id └─┘ ┴ ┴ ┴ ┴ ┴
src └─┘ ┴ ┴ ┴
typ └─┘ ┴ ┴ ┴ ┴ ┴
537 ⟨λ h, le_antisymm
id ┴ └─────────┘
src └─────────┘
typ ┴ └─────────┘
538 (le_of_not_gt (λ h0, lt_irrefl (0 : ℝ) $
id └──────────┘ └┘ └───────┘ ┴
src └──────────┘ └───────┘ ┴
typ └──────────┘ └┘ └───────┘ ┴
539 calc 0 < sin x : sin_pos_of_pos_of_lt_pi h0 hx₂
id └─┘ ┴ └─────────────────────┘ └┘ └─┘
src └─┘ └─────────────────────┘
typ └─┘ ┴ └─────────────────────┘ └┘ └─┘
540 ... = 0 : h))
id ┴
typ ┴
541 (le_of_not_gt (λ h0, lt_irrefl (0 : ℝ) $
id └──────────┘ └┘ └───────┘ ┴
src └──────────┘ └───────┘ ┴
typ └──────────┘ └┘ └───────┘ ┴
542 calc 0 = sin x : h.symm
id └─┘ ┴ ┴└───┘
src └─┘ └───┘
typ └─┘ ┴ ┴└───┘
543 ... < 0 : sin_neg_of_neg_of_neg_pi_lt h0 hx₁)),
id └─────────────────────────┘ └┘ └─┘
src └─────────────────────────┘
typ └─────────────────────────┘ └┘ └─┘
544 λ h, by simp [h]⟩
id ┴ ┴
src └────┘ ┴
typ ┴ └────┘┴┴
doc └────┘ ┴
txt └────┘ ┴
par └────┘ ┴
pid ┴┴ ┴
st └───────┘
545
546 lemma sin_eq_zero_iff {x : ℝ} : sin x = 0 ↔ ∃ n : ℤ, (n : ℝ) * π = x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴
547 ⟨λ h, ⟨⌊x / π⌋, le_antisymm (sub_nonneg.1 (sub_floor_div_mul_nonneg _ pi_pos))
id ┴ ┴┴ ┴ ┴┴ └─────────┘ └────────┘┴ └──────────────────────┘ └────┘
src ┴ ┴ ┴┴ └─────────┘ └────────┘┴ └──────────────────────┘ └────┘
typ ┴ ┴┴ ┴ ┴┴ └─────────┘ └────────┘┴ └──────────────────────┘ └────┘
doc ┴ ┴┴
548 (sub_nonpos.1 $ le_of_not_gt $ λ h₃, ne_of_lt (sin_pos_of_pos_of_lt_pi h₃ (sub_floor_div_mul_lt _ pi_pos))
id └────────┘┴ └──────────┘ └┘ └──────┘ └─────────────────────┘ └┘ └──────────────────┘ └────┘
src └────────┘┴ └──────────┘ └──────┘ └─────────────────────┘ └──────────────────┘ └────┘
typ └────────┘┴ └──────────┘ └┘ └──────┘ └─────────────────────┘ └┘ └──────────────────┘ └────┘
549 (by simp [sin_add, h, sin_int_mul_pi]))⟩,
id └─────┘ ┴ └────────────┘
src └────┘└─────┘└┘ └┘└────────────┘┴
typ └────┘└─────┘└┘┴└┘└────────────┘┴
doc └────┘ └┘ └┘ ┴
txt └────┘ └┘ └┘ ┴
par └────┘ └┘ └┘ ┴
pid ┴┴ └┘ └┘ ┴
st └────────────────────────────────┘
550 λ ⟨n, hn⟩, hn ▸ sin_int_mul_pi _⟩
id ┴ └┘ ┴ └────────────┘
src ┴ └────────────┘
typ ┴ └┘ ┴ └────────────┘
551
552 lemma sin_eq_zero_iff_cos_eq {x : ℝ} : sin x = 0 ↔ cos x = 1 ∨ cos x = -1 :=
id ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
553 by rw [← mul_self_eq_one_iff (cos x), ← sin_sq_add_cos_sq x,
id └─────────────────┘ └─┘ ┴ └───────────────┘ ┴
src └────┘└─────────────────┘┴ └─┘┴ └───┘└───────────────┘┴ └─
typ └────┘└─────────────────┘┴ └─┘┴┴└───┘└───────────────┘┴┴└─
doc └────┘ ┴ ┴ └───┘ ┴ └─
txt └────┘ ┴ ┴ └───┘ ┴ └─
par └────┘ ┴ ┴ └───┘ ┴ └─
pid └──┘ ┴ ┴ └───┘ ┴ └─
st └────────────────────────────────┘└─────────────────────┘└─
554 pow_two, pow_two, ← sub_eq_iff_eq_add, sub_self];
id └─────┘ └─────┘ └───────────────┘ └──────┘
src ───┘└─────┘└┘└─────┘└──┘└───────────────┘└┘└──────┘┴
typ ───┘└─────┘└┘└─────┘└──┘└───────────────┘└┘└──────┘┴
doc ───┘ └┘ └──┘ └┘ ┴
txt ───┘ └┘ └──┘ └┘ ┴
par ───┘ └┘ └──┘ └┘ ┴
pid ───┘ └┘ └──┘ └┘ ┴
st ──────────┘└───────┘└───────────────────┘└────────┘┴└─
555 exact ⟨λ h, by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ eq.symm⟩
id ┴ └──────┘ └─────────────────────────┘ ┴ └─────┘
src └────┘ └──┘ ┴└──┘ └┘└──────┘┴└┘└─────────────────────────┘┴┴┴└─────┘└─
typ └────┘ └──┘ ┴└──┘┴└┘└──────┘┴└┘└─────────────────────────┘┴┴┴└─────┘└─
doc └────┘ └──┘ ┴└──┘ └┘ ┴└┘ ┴ ┴ └─
txt └────┘ └──┘ ┴└──┘ └┘ ┴└┘ ┴ ┴ └─
par └────┘ └──┘ ┴└──┘ └┘ ┴└┘ ┴ ┴ └─
pid ┴ └──┘ └───┘ └┘ └─┘ ┴ ┴ ┴└
st ───────────────┘└────┘└────────┘┴└────────────────────────────────────────
556
src ┘
typ ┘
doc ┘
txt ┘
par ┘
pid ┘
st ┘
557 theorem sin_sub_sin (θ ψ : ℝ) : sin θ - sin ψ = 2 * sin((θ - ψ)/2) * cos((θ + ψ)/2) :=
id ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
558 begin
st └─────
559 have s1 := sin_add ((θ + ψ) / 2) ((θ - ψ) / 2),
id └─────┘ ┴ ┴ ┴ ┴ ┴
src └─────────┘└─────┘┴ ┴┴┴ └┘┴└──┘ ┴┴┴ └┘ └─┘
typ └─────────┘└─────┘┴ ┴┴┴ └┘┴└──┘ ┴┴┴┴┴└┘ └─┘
doc └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
txt └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
par └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
pid └─────┘┴└─┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
st ───────────────────────────────────────────────┘└─
560 have s2 := sin_sub ((θ + ψ) / 2) ((θ - ψ) / 2),
id └─────┘ ┴ ┴
src └─────────┘└─────┘┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
typ └─────────┘└─────┘┴ ┴ ┴ └┘ └──┘ ┴┴ ┴┴└┘ └─┘
doc └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
txt └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
par └─────────┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
pid └─────┘┴└─┘ ┴ ┴ ┴ └┘ └──┘ ┴ ┴ └┘ └─┘
st ───────────────────────────────────────────────┘└─
561 rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, add_self_div_two] at s1,
id └──────────────┘ └─────┘ └────────────┘ └────────────┘ └──────────────┘
src └──┘└──────────────┘└┘└─────┘└┘└────────────┘└┘└────────────┘└┘└──────────────┘└─────┘
typ └──┘└──────────────┘└┘└─────┘└┘└────────────┘└┘└────────────┘└┘└──────────────┘└─────┘
doc └──┘ └┘ └┘ └┘ └┘ └─────┘
txt └──┘ └┘ └┘ └┘ └┘ └─────┘
par └──┘ └┘ └┘ └┘ └┘ └─────┘
pid └┘ └┘ └┘ └┘ └┘ ┴└────┘
st ─────────────────────┘└───────┘└──────────────┘└──────────────┘└────────────────┘┴└────┘└─
562 rw [div_sub_div_same, ←sub_add, add_sub_cancel', add_self_div_two] at s2,
id └──────────────┘ └─────┘ └─────────────┘ └──────────────┘
src └──┘└──────────────┘└─┘└─────┘└┘└─────────────┘└┘└──────────────┘└─────┘
typ └──┘└──────────────┘└─┘└─────┘└┘└─────────────┘└┘└──────────────┘└─────┘
doc └──┘ └─┘ └┘ └┘ └─────┘
txt └──┘ └─┘ └┘ └┘ └─────┘
par └──┘ └─┘ └┘ └┘ └─────┘
pid └┘ └─┘ └┘ └┘ ┴└────┘
st ─────────────────────┘└────────┘└───────────────┘└────────────────┘┴└────┘└─
563 rw [s1, s2, ←sub_add, add_sub_cancel', ← two_mul, ← mul_assoc, mul_right_comm]
id └┘ └┘ └─────┘ └─────────────┘ └─────┘ └───────┘ └────────────┘
src └──┘ └┘ └─┘└─────┘└┘└─────────────┘└──┘└─────┘└──┘└───────┘└┘└────────────┘└┘
typ └──┘└┘└┘└┘└─┘└─────┘└┘└─────────────┘└──┘└─────┘└──┘└───────┘└┘└────────────┘└┘
doc └──┘ └┘ └─┘ └┘ └──┘ └──┘ └┘ └┘
txt └──┘ └┘ └─┘ └┘ └──┘ └──┘ └┘ └┘
par └──┘ └┘ └─┘ └┘ └──┘ └──┘ └┘ └┘
pid └┘ └┘ └─┘ └┘ └──┘ └──┘ └┘ ┴┴
st ───────┘└──┘└────────┘└───────────────┘└─────────┘└───────────┘└──────────────┘┴┴
564 end
st └─┘
565
566 lemma cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π) = x :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴
567 ⟨λ h, let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (or.inl h)) in
id ┴ └─┘ ┴ └─────────────┘┴ └────────────────────┘┴ └────┘ ┴
src └─────────────┘┴ └────────────────────┘┴ └────┘
typ ┴ └─┘ ┴ └─────────────┘┴ └────────────────────┘┴ └────┘ ┴
568 ⟨n / 2, (int.mod_two_eq_zero_or_one n).elim
id ┴ └────────────────────────┘ └──┘
src ┴ └────────────────────────┘ └──┘
typ ┴ └────────────────────────┘ └──┘
569 (λ hn0, by rwa [← mul_assoc, ← @int.cast_two ℝ, ← int.cast_mul, int.div_mul_cancel
id └─┘ └───────┘ └──────────┘ └──────────┘ └────────────────┘
src └─────┘└───────┘└──┘ └──────────┘┴ └──┘└──────────┘└┘└────────────────┘└
typ └─┘ └─────┘└───────┘└──┘ └──────────┘┴ └──┘└──────────┘└┘└────────────────┘└
doc └─────┘ └──┘ ┴ └──┘ └┘ └
txt └─────┘ └──┘ ┴ └──┘ └┘ └
par └─────┘ └──┘ ┴ └──┘ └┘ └
pid └──┘ └──┘ ┴ └──┘ └┘ └
st └───────────────┘└─────────────────┘└──────────────┘└────────────────────
570 ((int.dvd_iff_mod_eq_zero _ _).2 hn0)])
id └─────────────────────┘ └─┘
src ───────┘ └─────────────────────┘└──────┘ └┘
typ ───────┘ └─────────────────────┘└──────┘└─┘└┘
doc ───────┘ └──────┘ └┘
txt ───────┘ └──────┘ └┘
par ───────┘ └──────┘ └┘
pid ───────┘ └──────┘ └┘
st ────────────────────────────────────────────┘┴
571 (λ hn1, by rw [← int.mod_add_div n 2, hn1, int.cast_add, int.cast_one, add_mul,
id └─┘ └─────────────┘ ┴ └─┘ └──────────┘ └──────────┘ └─────┘
src └────┘└─────────────┘┴ └──┘ └┘└──────────┘└┘└──────────┘└┘└─────┘└─
typ └─┘ └────┘└─────────────┘┴┴└──┘└─┘└┘└──────────┘└┘└──────────┘└┘└─────┘└─
doc └────┘ ┴ └──┘ └┘ └┘ └┘ └─
txt └────┘ ┴ └──┘ └┘ └┘ └┘ └─
par └────┘ ┴ └──┘ └┘ └┘ └┘ └─
pid └──┘ ┴ └──┘ └┘ └┘ └┘ └─
st └───────────────────────┘└────┘└────────────┘└────────────┘└───────┘└─
572 one_mul, add_comm, mul_comm (2 : ℤ), int.cast_mul, mul_assoc, int.cast_two] at hn;
id └─────┘ └──────┘ └──────┘ └──────────┘ └───────┘ └──────────┘
src ─────────┘└─────┘└┘└──────┘└┘└──────┘┴ └──┘ └─┘└──────────┘└┘└───────┘└┘└──────────┘└─────┘
typ ─────────┘└─────┘└┘└──────┘└┘└──────┘┴ └──┘ └─┘└──────────┘└┘└───────┘└┘└──────────┘└─────┘
doc ─────────┘ └┘ └┘ ┴ └──┘ └─┘ └┘ └┘ └─────┘
txt ─────────┘ └┘ └┘ ┴ └──┘ └─┘ └┘ └┘ └─────┘
par ─────────┘ └┘ └┘ ┴ └──┘ └─┘ └┘ └┘ └─────┘
pid ─────────┘ └┘ └┘ ┴ └──┘ └─┘ └┘ └┘ ┴└────┘
st ────────────────┘└────────┘└────────────────┘└────────────┘└─────────┘└────────────┘┴└───────
573 rw [← hn, cos_int_mul_two_pi_add_pi] at h;
id └┘ └───────────────────────┘
src └────┘ └┘└───────────────────────┘└────┘
typ └────┘└┘└┘└───────────────────────┘└────┘
doc └────┘ └┘ └────┘
txt └────┘ └┘ └────┘
par └────┘ └┘ └────┘
pid └──┘ └┘ ┴└───┘
st ───────────┘└──┘└─────────────────────────┘┴└──────
574 exact absurd h (by norm_num))⟩,
id └────┘ ┴
src └────┘└────┘┴ ┴ ┴└──────┘┴
typ └────┘└────┘┴┴┴ ┴└──────┘┴
doc └────┘ ┴ ┴ ┴└──────┘┴
txt └────┘ ┴ ┴ ┴└──────┘┴
par └────┘ ┴ ┴ ┴└──────┘┴
pid ┴ ┴ ┴ └────────┘
st ─────────────────────────┘└───────┘┴
575 λ ⟨n, hn⟩, hn ▸ cos_int_mul_two_pi _⟩
id ┴ └┘ ┴ └────────────────┘
src ┴ └────────────────┘
typ ┴ └┘ ┴ └────────────────┘
576
577 theorem cos_eq_zero_iff {θ : ℝ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * pi / 2 :=
id ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
src ┴ └─┘ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ └┘ ┴
typ ┴ └─┘ ┴ ┴ ┴ ┴ ┴┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴
doc └┘
578 begin
st └─────
579 rw [←real.sin_pi_div_two_sub, sin_eq_zero_iff],
id └─────────────────────┘ └─────────────┘
src └───┘└─────────────────────┘└┘└─────────────┘┴
typ └───┘└─────────────────────┘└┘└─────────────┘┴
doc └───┘ └┘ ┴
txt └───┘ └┘ ┴
par └───┘ └┘ ┴
pid └─┘ └┘ ┴
st ─────────────────────────────┘└───────────────┘└──
580 split,
src └───┘
typ └───┘
doc └───┘
txt └───┘
par └───┘
st ──────┘└─
581 { rintro ⟨n, hn⟩, existsi -n,
id ┴┴
src └────────────┘ └──────┘┴
typ └────────────┘ └──────┘┴┴
doc └────────────┘ └──────┘
txt └────────────┘ └──────┘
par └────────────┘ └──────┘
pid └──────┘ ┴
st ───┘└────────────┘└──────────┘└─
582 rw [int.cast_neg, add_mul, add_div, mul_assoc, mul_div_cancel_left _ two_ne_zero,
id └──────────┘ └─────┘ └─────┘ └───────┘ └─────────────────┘ └─────────┘
src └──┘└──────────┘└┘└─────┘└┘└─────┘└┘└───────┘└┘└─────────────────┘└─┘└─────────┘└─
typ └──┘└──────────┘└┘└─────┘└┘└─────┘└┘└───────┘└┘└─────────────────┘└─┘└─────────┘└─
doc └──┘ └┘ └┘ └┘ └┘ └─┘ └─
txt └──┘ └┘ └┘ └┘ └┘ └─┘ └─
par └──┘ └┘ └┘ └┘ └┘ └─┘ └─
pid └┘ └┘ └┘ └┘ └┘ └─┘ └─
st ───────────────────┘└───────┘└───────┘└─────────┘└─────────────────────────────────┘└─
583 one_mul, ←neg_mul_eq_neg_mul, hn, neg_sub, sub_add_cancel] },
id └─────┘ └────────────────┘ └┘ └─────┘ └────────────┘
src ───────┘└─────┘└─┘└────────────────┘└┘ └┘└─────┘└┘└────────────┘└┘
typ ───────┘└─────┘└─┘└────────────────┘└┘└┘└┘└─────┘└┘└────────────┘└┘
doc ───────┘ └─┘ └┘ └┘ └┘ └┘
txt ───────┘ └─┘ └┘ └┘ └┘ └┘
par ───────┘ └─┘ └┘ └┘ └┘ └┘
pid ───────┘ └─┘ └┘ └┘ └┘ ┴┴
st ──────────────┘└───────────────────┘└──┘└───────┘└──────────────┘┴┴└┘└
584 { rintro ⟨n, hn⟩, existsi -n,
id ┴
src └────────────┘ └──────┘
typ └────────────┘ └──────┘ ┴
doc └────────────┘ └──────┘
txt └────────────┘ └──────┘
par └────────────┘ └──────┘
pid └──────┘ ┴
st ─────────────────┘└──────────┘└─
585 rw [hn, add_mul, one_mul, add_div, mul_assoc, mul_div_cancel_left _ two_ne_zero,
id └┘ └─────┘ └─────┘ └─────┘ └───────┘ └─────────────────┘ └─────────┘
src └──┘ └┘└─────┘└┘└─────┘└┘└─────┘└┘└───────┘└┘└─────────────────┘└─┘└─────────┘└─
typ └──┘└┘└┘└─────┘└┘└─────┘└┘└─────┘└┘└───────┘└┘└─────────────────┘└─┘└─────────┘└─
doc └──┘ └┘ └┘ └┘ └┘ └┘ └─┘ └─
txt └──┘ └┘ └┘ └┘ └┘ └┘ └─┘ └─
par └──┘ └┘ └┘ └┘ └┘ └┘ └─┘ └─
pid └┘ └┘ └┘ └┘ └┘ └┘ └─┘ └─
st ─────────┘└───────┘└───────┘└───────┘└─────────┘└─────────────────────────────────┘└─
586 sub_add_eq_sub_sub_swap, sub_self, zero_sub, neg_mul_eq_neg_mul, int.cast_neg] }
id └─────────────────────┘ └──────┘ └──────┘ └────────────────┘ └──────────┘
src ───────┘└─────────────────────┘└┘└──────┘└┘└──────┘└┘└────────────────┘└┘└──────────┘└┘
typ ───────┘└─────────────────────┘└┘└──────┘└┘└──────┘└┘└────────────────┘└┘└──────────┘└┘
doc ───────┘ └┘ └┘ └┘ └┘ └┘
txt ───────┘ └┘ └┘ └┘ └┘ └┘
par ───────┘ └┘ └┘ └┘ └┘ └┘
pid ───────┘ └┘ └┘ └┘ └┘ ┴┴
st ──────────────────────────────┘└────────┘└────────┘└──────────────────┘└────────────┘┴┴└─
587 end
st ──┘
588
589 lemma cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x < 2 * π) : cos x = 1 ↔ x = 0 :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
st ┴
590 ⟨λ h, let ⟨n, hn⟩ := (cos_eq_one_iff x).1 h in
id ┴ └─┘ └────────────┘ ┴ ┴ ┴
src └────────────┘ ┴
typ ┴ └─┘ └────────────┘ ┴ ┴ ┴
591 begin
st └─────
592 clear _let_match,
src └──────────────┘
typ └──────────────┘
doc └──────────────┘
txt └──────────────┘
par └──────────────┘
pid └─────────┘
st ─────────────────────┘└─
593 subst hn,
id └┘
src └────┘
typ └────┘└┘
doc └────┘
txt └────┘
par └────┘
pid ┴
st ─────────────┘└─
594 rw [mul_lt_iff_lt_one_left two_pi_pos, ← int.cast_one, int.cast_lt, ← int.le_sub_one_iff, sub_self] at hx₂,
id └────────────────────┘ └────────┘ └──────────┘ └─────────┘ └────────────────┘ └──────┘
src └──┘└────────────────────┘┴└────────┘└──┘└──────────┘└┘└─────────┘└──┘└────────────────┘└┘└──────┘└──────┘
typ └──┘└────────────────────┘┴└────────┘└──┘└──────────┘└┘└─────────┘└──┘└────────────────┘└┘└──────┘└──────┘
doc └──┘ ┴ └──┘ └┘ └──┘ └┘ └──────┘
txt └──┘ ┴ └──┘ └┘ └──┘ └┘ └──────┘
par └──┘ ┴ └──┘ └┘ └──┘ └┘ └──────┘
pid └┘ ┴ └──┘ └┘ └──┘ └┘ ┴└─────┘
st ──────────────────────────────────────────┘└──────────────┘└───────────┘└────────────────────┘└────────┘┴└─────┘└─
595 rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos, neg_lt,
id └────┘ └────────────────┘ └────────────────────┘ └────────┘ └────┘
src └──┘└────┘└┘└────────────────┘└┘└────────────────────┘┴└────────┘└┘└────┘└─
typ └──┘└────┘└┘└────────────────┘└┘└────────────────────┘┴└────────┘└┘└────┘└─
doc └──┘ └┘ └┘ ┴ └┘ └─
txt └──┘ └┘ └┘ ┴ └┘ └─
par └──┘ └┘ └┘ ┴ └┘ └─
pid └┘ └┘ └┘ ┴ └┘ └─
st ───────────────┘└──────────────────┘└─────────────────────────────────┘└──────┘└─
596 ← int.cast_one, ← int.cast_neg, int.cast_lt, ← int.add_one_le_iff, neg_add_self] at hx₁,
id └──────────┘ └──────────┘ └─────────┘ └────────────────┘ └──────────┘
src ─────────┘└──────────┘└──┘└──────────┘└┘└─────────┘└──┘└────────────────┘└┘└──────────┘└──────┘
typ ─────────┘└──────────┘└──┘└──────────┘└┘└─────────┘└──┘└────────────────┘└┘└──────────┘└──────┘
doc ─────────┘ └──┘ └┘ └──┘ └┘ └──────┘
txt ─────────┘ └──┘ └┘ └──┘ └┘ └──────┘
par ─────────┘ └──┘ └┘ └──┘ └┘ └──────┘
pid ─────────┘ └──┘ └┘ └──┘ └┘ ┴└─────┘
st ─────────────────────┘└──────────────┘└───────────┘└────────────────────┘└────────────┘┴└─────┘└─
597 exact mul_eq_zero.2 (or.inl (int.cast_eq_zero.2 (le_antisymm hx₂ hx₁))),
id └─────────┘ └────┘ └──────────────┘ └─────────┘ └─┘ └─┘
src └────┘└─────────┘└─┘ └────┘┴ └──────────────┘└─┘ └─────────┘┴ ┴ └─┘
typ └────┘└─────────┘└─┘ └────┘┴ └──────────────┘└─┘ └─────────┘┴└─┘┴└─┘└─┘
doc └────┘└─────────┘└─┘ ┴ └─┘ ┴ ┴ └─┘
txt └────┘ └─┘ ┴ └─┘ ┴ ┴ └─┘
par └────┘ └─┘ ┴ └─┘ ┴ ┴ └─┘
pid ┴ └─┘ ┴ └─┘ ┴ ┴ └─┘
st ────────────────────────────────────────────────────────────────────────────┘└─
598 end,
st ──────┘
599 λ h, by simp [h]⟩
id ┴ ┴
src └────┘ ┴
typ ┴ └────┘┴┴
doc └────┘ ┴
txt └────┘ ┴
par └────┘ ┴
pid ┴┴ ┴
st └───────┘
600
601 theorem cos_sub_cos (θ ψ : ℝ) : cos θ - cos ψ = -2 * sin((θ + ψ)/2) * sin((θ - ψ)/2) :=
id ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
src ┴ └─┘ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ └─┘ ┴ ┴
typ ┴ └─┘ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴ ┴ └─┘ ┴ ┴ ┴ ┴
602 by rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub, sin_sub_sin, sub_sub_sub_cancel_left,
id └────────────────┘ └────────────────┘
src └────┘└────────────────┘└──┘└────────────────┘└┘
typ └────┘└────────────────┘└──┘└────────────────┘└┘
doc └────┘ └──┘ └┘
txt └────┘ └──┘ └┘
par └────┘ └──┘ └┘
pid └──┘ └──┘ └┘
st └───────────────────────┘└────────────────────┘└┘
603 add_sub, sub_add_eq_add_sub, add_halves, sub_sub, sub_div π, cos_pi_div_two_sub,
604 ← neg_sub, neg_div, sin_neg, ← neg_mul_eq_mul_neg, neg_mul_eq_neg_mul, mul_right_comm]
st ┴
605
606 lemma cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π / 2)
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴
607 (hy₁ : 0 ≤ y) (hy₂ : y ≤ π / 2) (hxy : x < y) : cos y < cos x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴
608 calc cos y = cos x * cos (y - x) - sin x * sin (y - x) :
id ┴ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴
src ┴ └┘ └┘ └┘ └┘
typ ┴ ┴ └┘ ┴ └┘ ┴ ┴ └┘ ┴ └┘ ┴ ┴
609 by rw [← cos_add, add_sub_cancel'_right]
st ┴
610 ... < (cos x * 1) - sin x * sin (y - x) :
id └─┘ ┴ └─┘ ┴ └─┘ ┴ ┴
src └─┘ └─┘ └─┘
typ └─┘ ┴ └─┘ ┴ └─┘ ┴ ┴
611 sub_lt_sub_right ((mul_lt_mul_left
612 (cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two (lt_of_lt_of_le (neg_neg_of_pos pi_div_two_pos) hx₁)
613 (lt_of_lt_of_le hxy hy₂))).2
id └─┘
typ └─┘
614 (lt_of_le_of_ne (cos_le_one _) (mt (cos_eq_one_iff_of_lt_of_lt
615 (show -(2 * π) < y - x, by linarith) (show y - x < 2 * π, by linarith)).1
id ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
616 (sub_ne_zero.2 (ne_of_lt hxy).symm)))) _
id └─┘
typ └─┘
617 ... ≤ _ : by rw mul_one;
618 exact sub_le_self _ (mul_nonneg (sin_nonneg_of_nonneg_of_le_pi hx₁ (by linarith))
619 (sin_nonneg_of_nonneg_of_le_pi (by linarith) (by linarith)))
620
621 lemma cos_lt_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π)
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴
622 (hy₁ : 0 ≤ y) (hy₂ : y ≤ π) (hxy : x < y) : cos y < cos x :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
doc ┴
623 match (le_total x (π / 2) : x ≤ π / 2 ∨ π / 2 ≤ x), le_total y (π / 2) with
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴ ┴ ┴
624 | or.inl hx, or.inl hy := cos_lt_cos_of_nonneg_of_le_pi_div_two hx₁ hx hy₁ hy hxy
id ┴
typ ┴
625 | or.inl hx, or.inr hy := (lt_or_eq_of_le hx).elim
626 (λ hx, calc cos y ≤ 0 : cos_nonpos_of_pi_div_two_le_of_le hy (by linarith [pi_pos])
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
627 ... < cos x : cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two (by linarith) hx)
id └─┘ ┴
src └─┘
typ └─┘ ┴
628 (λ hx, calc cos y < 0 : cos_neg_of_pi_div_two_lt_of_lt (by linarith) (by linarith [pi_pos])
id └─┘ ┴
src └─┘
typ └─┘ ┴
629 ... = cos x : by rw [hx, cos_pi_div_two])
id └─┘ ┴
src └─┘
typ └─┘ ┴
st ┴
630 | or.inr hx, or.inl hy := by linarith
631 | or.inr hx, or.inr hy := neg_lt_neg_iff.1 (by rw [← cos_pi_sub, ← cos_pi_sub];
632 apply cos_lt_cos_of_nonneg_of_le_pi_div_two; linarith)
633 end
634
635 lemma cos_le_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π)
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴
636 (hy₁ : 0 ≤ y) (hy₂ : y ≤ π) (hxy : x ≤ y) : cos y ≤ cos x :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
doc ┴
637 (lt_or_eq_of_le hxy).elim
id └┘
typ └┘
638 (le_of_lt ∘ cos_lt_cos_of_nonneg_of_le_pi hx₁ hx₂ hy₁ hy₂)
id └┘ └┘
typ └┘ └┘
639 (λ h, h ▸ le_refl _)
id ┴ ┴
typ ┴ ┴
640
641 lemma sin_lt_sin_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) (hy₁ : -(π / 2) ≤ y)
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴ ┴
642 (hy₂ : y ≤ π / 2) (hxy : x < y) : sin x < sin y :=
id ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
doc ┴
643 by rw [← cos_sub_pi_div_two, ← cos_sub_pi_div_two, ← cos_neg (x - _), ← cos_neg (y - _)];
id ┴ ┴
typ ┴ ┴
644 apply cos_lt_cos_of_nonneg_of_le_pi; linarith
645
646 lemma sin_le_sin_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) (hy₁ : -(π / 2) ≤ y)
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴ ┴
647 (hy₂ : y ≤ π / 2) (hxy : x ≤ y) : sin x ≤ sin y :=
id ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
doc ┴
648 (lt_or_eq_of_le hxy).elim
id └┘
typ └┘
649 (le_of_lt ∘ sin_lt_sin_of_le_of_le_pi_div_two hx₁ hx₂ hy₁ hy₂)
650 (λ h, h ▸ le_refl _)
651
652 lemma sin_inj_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) (hy₁ : -(π / 2) ≤ y)
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴ ┴
653 (hy₂ : y ≤ π / 2) (hxy : sin x = sin y) : x = y :=
id ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ ┴ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴
doc ┴
654 match lt_trichotomy x y with
id ┴ ┴
typ ┴ ┴
655 | or.inl h := absurd (sin_lt_sin_of_le_of_le_pi_div_two hx₁ hx₂ hy₁ hy₂ h) (by rw hxy; exact lt_irrefl _)
656 | or.inr (or.inl h) := h
id ┴
typ ┴
657 | or.inr (or.inr h) := absurd (sin_lt_sin_of_le_of_le_pi_div_two hy₁ hy₂ hx₁ hx₂ h) (by rw hxy; exact lt_irrefl _)
658 end
659
660 lemma cos_inj_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π) (hy₁ : 0 ≤ y) (hy₂ : y ≤ π)
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
661 (hxy : cos x = cos y) : x = y :=
id └┘ ┴ ┴ ┴ ┴ ┴
src └┘ ┴
typ └┘ ┴ ┴ ┴ ┴ ┴
662 begin
663 rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub] at hxy,
664 refine (sub_left_inj).1 (sin_inj_of_le_of_le_pi_div_two _ _ _ _ hxy);
665 linarith
666 end
st └─┘
667
668 lemma exists_sin_eq : set.Icc (-1:ℝ) 1 ⊆ sin '' set.Icc (-(π / 2)) (π / 2) :=
id ┴ └┘ ┴ ┴
src ┴ └┘ ┴ ┴
typ ┴ └┘ ┴ ┴
doc ┴ ┴
669 by convert intermediate_value_Icc
670 (le_trans (neg_nonpos.2 (le_of_lt pi_div_two_pos)) (le_of_lt pi_div_two_pos))
671 continuous_sin.continuous_on; simp only [sin_neg, sin_pi_div_two]
672
673 lemma sin_lt {x : ℝ} (h : 0 < x) : sin x < x :=
id ┴ └┘ ┴ ┴
src ┴ └┘
typ ┴ └┘ ┴ ┴
674 begin
675 cases le_or_gt x 1 with h' h',
676 { have hx : abs x = x := abs_of_nonneg (le_of_lt h),
id ┴
typ ┴
677 have : abs x ≤ 1, rwa [hx],
id ┴
typ ┴
678 have := sin_bound this, rw [abs_le] at this,
679 have := this.2, rw [sub_le_iff_le_add', hx] at this,
680 apply lt_of_le_of_lt this, rw [sub_add], apply lt_of_lt_of_le _ (le_of_eq (sub_zero x)),
id ┴
typ ┴
681 apply sub_lt_sub_left, rw sub_pos, apply mul_lt_mul',
682 { rw [pow_succ x 3], refine le_trans _ (le_of_eq (one_mul _)),
id ┴
typ ┴
683 rw mul_le_mul_right, exact h', apply pow_pos h },
st └┘
684 norm_num, norm_num, apply pow_pos h },
st └┘
685 exact lt_of_le_of_lt (sin_le_one x) h'
id ┴
typ ┴
686 end
st └─┘
687
688 /- note 1: this inequality is not tight, the tighter inequality is sin x > x - x ^ 3 / 6.
689 note 2: this is also true for x > 1, but it's nontrivial for x just above 1. -/
690 lemma sin_gt_sub_cube {x : ℝ} (h : 0 < x) (h' : x ≤ 1) : x - x ^ 3 / 4 < sin x :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴
691 begin
692 have hx : abs x = x := abs_of_nonneg (le_of_lt h),
id ┴
typ ┴
693 have : abs x ≤ 1, rwa [hx],
id ┴
typ ┴
694 have := sin_bound this, rw [abs_le] at this,
695 have := this.1, rw [le_sub_iff_add_le, hx] at this,
696 refine lt_of_lt_of_le _ this,
697 rw [add_comm, sub_add, sub_neg_eq_add], apply sub_lt_sub_left,
698 apply add_lt_of_lt_sub_left,
699 rw (show x ^ 3 / 4 - x ^ 3 / 6 = x ^ 3 / 12,
id ┴
typ ┴
700 by simp [div_eq_mul_inv, (mul_sub _ _ _).symm, -sub_eq_add_neg]; congr; norm_num),
id └───┘
src └───┘
typ └───┘
701 apply mul_lt_mul',
702 { rw [pow_succ x 3], refine le_trans _ (le_of_eq (one_mul _)),
id ┴
typ ┴
703 rw mul_le_mul_right, exact h', apply pow_pos h },
st └┘
704 norm_num, norm_num, apply pow_pos h
705 end
st └─┘
706
707 /-- The type of angles -/
708 def angle : Type :=
709 quotient_add_group.quotient (gmultiples (2 * π))
id ┴
src ┴
typ ┴
doc ┴
710
711 namespace angle
712
713 instance angle.add_comm_group : add_comm_group angle :=
id ┴ └┘ └┘ └┘ └───┘
src ┴ └┘ └┘ └┘ └───┘
typ ┴ └┘ └┘ └┘ └───┘
doc └───┘
714 quotient_add_group.add_comm_group _
715
716 instance : inhabited angle := ⟨0⟩
id └───┘
src └───┘
typ └───┘
doc └───┘
717
718 instance angle.has_coe : has_coe ℝ angle :=
id ┴ └───┘
src ┴ └───┘
typ ┴ └───┘
doc └───┘
719 ⟨quotient.mk'⟩
720
721 instance angle.is_add_group_hom : is_add_group_hom (coe : ℝ → angle) :=
id ┴ └───┘
src ┴ └───┘
typ ┴ └───┘
doc └───┘
722 @quotient_add_group.is_add_group_hom _ _ _ (normal_add_subgroup_of_add_comm_group _)
723
724 @[simp] lemma coe_zero : ↑(0 : ℝ) = (0 : angle) := rfl
id ┴ └───┘
src ┴ └───┘
typ ┴ └───┘
doc └──┘ └───┘
725 @[simp] lemma coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : angle) := rfl
id ┴ ┴ ┴ ┴ ┴ ┴ └───┘
src ┴ ┴ └───┘
typ ┴ ┴ ┴ ┴ ┴ ┴ └───┘
doc └──┘ └───┘
726 @[simp] lemma coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : angle) := rfl
id ┴ ┴ ┴ ┴ └───┘
src ┴ ┴ └───┘
typ ┴ ┴ ┴ ┴ └───┘
doc └──┘ └───┘
727 @[simp] lemma coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : angle) := rfl
id ┴ ┴ ┴ ┴ ┴ ┴ └───┘
src ┴ ┴ └───┘
typ ┴ ┴ ┴ ┴ ┴ ┴ └───┘
doc └──┘ └───┘
728 @[simp] lemma coe_gsmul (x : ℝ) (n : ℤ) : ↑(gsmul n x : ℝ) = gsmul n (↑x : angle) := is_add_group_hom.map_gsmul _ _ _
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───┘
src ┴ ┴ ┴ └───┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └───┘
doc └──┘ └───┘
729 @[simp] lemma coe_two_pi : ↑(2 * π : ℝ) = (0 : angle) :=
id ┴ ┴ └───┘
src ┴ ┴ └───┘
typ ┴ ┴ └───┘
doc └──┘ ┴ └───┘
730 quotient.sound' ⟨-1, by dsimp only; rw [neg_one_gsmul, add_zero]⟩
st ┴
731
732 lemma angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k :=
id ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └───┘ ┴ ┴ ┴
typ ┴ ┴ └───┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └───┘ ┴
733 by simp only [quotient_add_group.eq, gmultiples, set.mem_range, gsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
734
735 theorem cos_eq_iff_eq_or_eq_neg {θ ψ : ℝ} : cos θ = cos ψ ↔ (θ : angle) = ψ ∨ (θ : angle) = -ψ :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴
src ┴ └┘ ┴ ┴ └───┘ ┴ └───┘
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴
doc └───┘ └───┘
736 begin
737 split,
738 { intro Hcos,
739 rw [←sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero, eq_false_intro two_ne_zero,
740 false_or, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos,
741 rcases Hcos with ⟨n, hn⟩ | ⟨n, hn⟩,
742 { right,
743 rw [eq_div_iff_mul_eq _ _ two_ne_zero, ← sub_eq_iff_eq_add] at hn,
744 rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc,
745 ← gsmul_eq_mul, coe_gsmul, mul_comm, coe_two_pi, gsmul_zero] },
st ┴ └┘
746 { left,
747 rw [eq_div_iff_mul_eq _ _ two_ne_zero, eq_sub_iff_add_eq] at hn,
748 rw [← hn, coe_add, mul_assoc,
749 ← gsmul_eq_mul, coe_gsmul, mul_comm, coe_two_pi, gsmul_zero, zero_add] } },
st ┴ └──┘
750 { rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub],
751 rintro (⟨k, H⟩ | ⟨k, H⟩),
752 rw [← sub_eq_zero_iff_eq, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left _ two_ne_zero,
id ┴
typ ┴
753 mul_comm π _, sin_int_mul_pi, mul_zero],
754 rw [←sub_eq_zero_iff_eq, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k,
id ┴
typ ┴
755 mul_div_cancel_left _ two_ne_zero, mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] }
st ┴ └─
756 end
st ──┘
757
758 theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : ℝ} : sin θ = sin ψ ↔ (θ : angle) = ψ ∨ (θ : angle) + ψ = π :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴ ┴
src ┴ └┘ ┴ ┴ └───┘ ┴ └───┘ ┴
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ └───┘ ┴ ┴ ┴ └───┘ ┴ ┴
doc └───┘ └───┘ ┴
759 begin
760 split,
761 { intro Hsin, rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin,
762 cases cos_eq_iff_eq_or_eq_neg.mp Hsin with h h,
763 { left, rw coe_sub at h, exact sub_left_inj.1 h },
st └┘
764 right, rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub,
765 sub_add_eq_add_sub, ← coe_add, add_halves, sub_sub, sub_eq_zero] at h,
766 exact h.symm },
st └┘
767 { rw [angle_eq_iff_two_pi_dvd_sub, ←eq_sub_iff_add_eq, ←coe_sub, angle_eq_iff_two_pi_dvd_sub],
768 rintro (⟨k, H⟩ | ⟨k, H⟩),
769 rw [← sub_eq_zero_iff_eq, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left _ two_ne_zero,
id ┴
typ ┴
770 mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul],
771 have H' : θ + ψ = (2 * k) * π + π := by rwa [←sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add,
id ┴ ┴ ┴
typ ┴ ┴ ┴
772 mul_assoc, mul_comm π _, ←mul_assoc] at H,
773 rw [← sub_eq_zero_iff_eq, sin_sub_sin, H', add_div, mul_assoc 2 _ π, mul_div_cancel_left _ two_ne_zero,
774 cos_add_pi_div_two, sin_int_mul_pi, neg_zero, mul_zero] }
st ┴ └─
775 end
st ──┘
776
777 theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : angle) = ψ :=
id ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ └───┘ ┴
src ┴ └┘ ┴ └┘ ┴ └───┘
typ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴ └───┘ ┴
doc └───┘
778 begin
779 cases cos_eq_iff_eq_or_eq_neg.mp Hcos with hc hc, { exact hc },
st └┘
780 cases sin_eq_iff_eq_or_add_eq_pi.mp Hsin with hs hs, { exact hs },
st └┘
781 rw [eq_neg_iff_add_eq_zero, hs] at hc,
782 cases quotient.exact' hc with n hn, dsimp only at hn,
783 rw [← neg_one_mul, add_zero, ← sub_eq_zero_iff_eq, gsmul_eq_mul, ← mul_assoc, ← sub_mul,
784 mul_eq_zero, eq_false_intro (ne_of_gt pi_pos), or_false, sub_neg_eq_add,
785 ← int.cast_zero, ← int.cast_one, ← int.cast_bit0, ← int.cast_mul, ← int.cast_add, int.cast_inj] at hn,
786 have : (n * 2 + 1) % (2:ℤ) = 0 % (2:ℤ) := congr_arg (%(2:ℤ)) hn,
id ┴ ┴
typ ┴ ┴
787 rw [add_comm, int.add_mul_mod_self] at this,
788 exact absurd this one_ne_zero
789 end
st └─┘
790
791 end angle
792
793 /-- Inverse of the `sin` function, returns values in the range `-π / 2 ≤ arcsin x` and `arcsin x ≤ π / 2`.
794 If the argument is not between `-1` and `1` it defaults to `0` -/
795 noncomputable def arcsin (x : ℝ) : ℝ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
796 if hx : -1 ≤ x ∧ x ≤ 1 then classical.some (exists_sin_eq hx) else 0
id ┴ ┴
typ ┴ ┴
797
798 lemma arcsin_le_pi_div_two (x : ℝ) : arcsin x ≤ π / 2 :=
id ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴ ┴
typ ┴ └┘ ┴ ┴ ┴
doc └┘ ┴ ┴
799 if hx : -1 ≤ x ∧ x ≤ 1
id ┴ ┴
typ ┴ ┴
800 then by rw [arcsin, dif_pos hx]; exact (classical.some_spec (exists_sin_eq hx)).1.2
801 else by rw [arcsin, dif_neg hx]; exact le_of_lt pi_div_two_pos
802
803 lemma neg_pi_div_two_le_arcsin (x : ℝ) : -(π / 2) ≤ arcsin x :=
id ┴ ┴ └┘ └┘ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ └┘ └┘ ┴
doc ┴ └┘ └┘
804 if hx : -1 ≤ x ∧ x ≤ 1
id ┴ ┴
typ ┴ ┴
805 then by rw [arcsin, dif_pos hx]; exact (classical.some_spec (exists_sin_eq hx)).1.1
806 else by rw [arcsin, dif_neg hx]; exact neg_nonpos.2 (le_of_lt pi_div_two_pos)
807
808 lemma sin_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arcsin x) = x :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
doc └┘ ┴
809 by rw [arcsin, dif_pos (and.intro hx₁ hx₂)];
810 exact (classical.some_spec (exists_sin_eq ⟨hx₁, hx₂⟩)).2
811
812 lemma arcsin_sin {x : ℝ} (hx₁ : -(π / 2) ≤ x) (hx₂ : x ≤ π / 2) : arcsin (sin x) = x :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ └┘ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
doc ┴ ┴ └┘ ┴
813 sin_inj_of_le_of_le_pi_div_two (neg_pi_div_two_le_arcsin _) (arcsin_le_pi_div_two _) hx₁ hx₂
814 (by rw sin_arcsin (neg_one_le_sin _) (sin_le_one _))
815
816 lemma arcsin_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1)
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
817 (hxy : arcsin x = arcsin y) : x = y :=
id ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴
doc ┴ └┘ ┴ └┘
818 by rw [← sin_arcsin hx₁ hx₂, ← sin_arcsin hy₁ hy₂, hxy]
st ┴
819
820 @[simp] lemma arcsin_zero : arcsin 0 = 0 :=
id └┘ └┘
src └┘ └┘
typ └┘ └┘
doc └──┘ └┘ └┘
821 sin_inj_of_le_of_le_pi_div_two
822 (neg_pi_div_two_le_arcsin _)
823 (arcsin_le_pi_div_two _)
824 (neg_nonpos.2 (le_of_lt pi_div_two_pos))
825 (le_of_lt pi_div_two_pos)
826 (by rw [sin_arcsin, sin_zero]; norm_num)
827
828 @[simp] lemma arcsin_one : arcsin 1 = π / 2 :=
id └┘ └┘ ┴
src └┘ └┘ ┴
typ └┘ └┘ ┴
doc └──┘ └┘ └┘ ┴
829 sin_inj_of_le_of_le_pi_div_two
830 (neg_pi_div_two_le_arcsin _)
831 (arcsin_le_pi_div_two _)
832 (by linarith [pi_pos])
833 (le_refl _)
834 (by rw [sin_arcsin, sin_pi_div_two]; norm_num)
835
836 @[simp] lemma arcsin_neg (x : ℝ) : arcsin (-x) = -arcsin x :=
id ┴ └┘ └┘ ┴ └┘ ┴ ┴
src ┴ └┘ └┘ └┘ ┴
typ ┴ └┘ └┘ ┴ └┘ ┴ ┴
doc └──┘ └┘ └┘ └┘ ┴
837 if h : -1 ≤ x ∧ x ≤ 1 then
id ┴ ┴
typ ┴ ┴
838 have -1 ≤ -x ∧ -x ≤ 1, by rwa [neg_le_neg_iff, neg_le, and.comm],
id ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴
839 sin_inj_of_le_of_le_pi_div_two
840 (neg_pi_div_two_le_arcsin _)
841 (arcsin_le_pi_div_two _)
842 (neg_le_neg (arcsin_le_pi_div_two _))
843 (neg_le.1 (neg_pi_div_two_le_arcsin _))
844 (by rw [sin_arcsin this.1 this.2, sin_neg, sin_arcsin h.1 h.2])
st ┴
845 else
846 have ¬(-1 ≤ -x ∧ -x ≤ 1) := by rwa [neg_le_neg_iff, neg_le, and.comm],
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
847 by rw [arcsin, arcsin, dif_neg h, dif_neg this, neg_zero]
st ┴
848
849 @[simp] lemma arcsin_neg_one : arcsin (-1) = -(π / 2) := by simp
id └┘ └┘ ┴
src └┘ └┘ ┴
typ └┘ └┘ ┴
doc └──┘ └┘ └┘ ┴
850
851 lemma arcsin_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ arcsin x :=
id ┴ ┴ └┘ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ └┘ └┘ ┴
doc └┘ └┘
852 if hx₁ : x ≤ 1 then
id ┴
typ ┴
853 not_lt.1 (λ h, not_lt.2 hx begin
854 have := sin_lt_sin_of_le_of_le_pi_div_two
855 (neg_pi_div_two_le_arcsin _) (arcsin_le_pi_div_two _)
856 (neg_nonpos.2 (le_of_lt pi_div_two_pos)) (le_of_lt pi_div_two_pos) h,
857 rw [real.sin_arcsin, sin_zero] at this; linarith
858 end)
st └─┘
859 else by rw [arcsin, dif_neg]; simp [hx₁]
860
861 lemma arcsin_eq_zero_iff {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : arcsin x = 0 ↔ x = 0 :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
doc └┘ └┘
862 ⟨λ h, have sin (arcsin x) = 0, by simp [h],
id └─┘ └┘ ┴
src └─┘ └┘
typ └─┘ └┘ ┴
doc └┘
863 by rwa [sin_arcsin hx₁ hx₂] at this,
864 λ h, by simp [h]⟩
865
866 lemma arcsin_pos {x : ℝ} (hx₁ : 0 < x) (hx₂ : x ≤ 1) : 0 < arcsin x :=
id ┴ ┴ ┴ └┘ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ ┴ └┘ └┘ ┴
doc └┘ └┘
867 lt_of_le_of_ne (arcsin_nonneg (le_of_lt hx₁))
868 (ne.symm (mt (arcsin_eq_zero_iff (by linarith) hx₂).1 (ne_of_lt hx₁).symm))
869
870 lemma arcsin_nonpos {x : ℝ} (hx : x ≤ 0) : arcsin x ≤ 0 :=
id ┴ ┴ └┘ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ └┘ └┘ ┴
doc └┘ └┘
871 neg_nonneg.1 (arcsin_neg x ▸ arcsin_nonneg (neg_nonneg.2 hx))
id ┴
typ ┴
872
873 /-- Inverse of the `cos` function, returns values in the range `0 ≤ arccos x` and `arccos x ≤ π`.
874 If the argument is not between `-1` and `1` it defaults to `π / 2` -/
875 noncomputable def arccos (x : ℝ) : ℝ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
876 π / 2 - arcsin x
id ┴ └┘ └┘ ┴
src ┴ └┘ └┘
typ ┴ └┘ └┘ ┴
doc ┴ └┘ └┘
877
878 lemma arccos_eq_pi_div_two_sub_arcsin (x : ℝ) : arccos x = π / 2 - arcsin x := rfl
id ┴ └┘ ┴ ┴ └┘ └┘ ┴
src ┴ └┘ ┴ └┘ └┘
typ ┴ └┘ ┴ ┴ └┘ └┘ ┴
doc └┘ ┴ └┘ └┘
879
880 lemma arcsin_eq_pi_div_two_sub_arccos (x : ℝ) : arcsin x = π / 2 - arccos x := by simp [arccos]
id ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ └────┘
src ┴ └┘ └┘ ┴ ┴ └┘ └────┘
typ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴ └────┘
doc └┘ └┘ ┴ ┴ └┘ └────┘
881
882 lemma arccos_le_pi (x : ℝ) : arccos x ≤ π :=
id ┴ └┘ └┘ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ └┘ └┘ ┴ ┴
doc └┘ └┘ ┴
883 by unfold arccos; linarith [neg_pi_div_two_le_arcsin x]
id ┴
typ ┴
884
885 lemma arccos_nonneg (x : ℝ) : 0 ≤ arccos x :=
id ┴ └┘ └┘
src ┴ └┘ └┘
typ ┴ └┘ └┘
doc └┘ └┘
886 by unfold arccos; linarith [arcsin_le_pi_div_two x]
id ┴
typ ┴
887
888 lemma cos_arccos {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : cos (arccos x) = x :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
doc └┘ ┴
889 by rw [arccos, cos_pi_div_two_sub, sin_arcsin hx₁ hx₂]
st ┴
890
891 lemma arccos_cos {x : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π) : arccos (cos x) = x :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
src ┴ ┴ └┘ └┘ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴
doc ┴ └┘ └┘
892 by rw [arccos, ← sin_pi_div_two_sub, arcsin_sin]; simp; linarith
893
894 lemma arccos_inj {x y : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) (hy₁ : -1 ≤ y) (hy₂ : y ≤ 1)
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
895 (hxy : arccos x = arccos y) : x = y :=
id ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴ ┴ ┴
doc ┴ └┘ ┴ └┘
896 arcsin_inj hx₁ hx₂ hy₁ hy₂ $ by simp [arccos, *] at *
id └────┘
src └────┘
typ └────┘
doc └────┘
897
898 @[simp] lemma arccos_zero : arccos 0 = π / 2 := by simp [arccos]
id └┘ └┘ ┴ └────┘
src └┘ └┘ ┴ └────┘
typ └┘ └┘ ┴ └────┘
doc └──┘ └┘ └┘ ┴ └────┘
899
900 @[simp] lemma arccos_one : arccos 1 = 0 := by simp [arccos]
id └┘ └┘ └────┘
src └┘ └┘ └────┘
typ └┘ └┘ └────┘
doc └──┘ └┘ └┘ └────┘
901
902 @[simp] lemma arccos_neg_one : arccos (-1) = π := by simp [arccos, add_halves]
id └┘ └┘ ┴ └────┘
src └┘ └┘ ┴ └────┘
typ └┘ └┘ ┴ └────┘
doc └──┘ └┘ └┘ ┴ └────┘
903
904 lemma arccos_neg (x : ℝ) : arccos (-x) = π - arccos x :=
id ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴
src ┴ └┘ └┘ ┴ ┴ └┘
typ ┴ └┘ └┘ ┴ ┴ ┴ └┘ ┴
doc └┘ └┘ ┴ ┴ └┘
905 by rw [← add_halves π, arccos, arcsin_neg, arccos, add_sub_assoc, sub_sub_self]; simp
906
907 lemma cos_arcsin_nonneg (x : ℝ) : 0 ≤ cos (arcsin x) :=
id ┴ └┘ └┘ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ └┘ └┘ ┴ ┴
doc └┘ ┴
908 cos_nonneg_of_neg_pi_div_two_le_of_le_pi_div_two
909 (neg_pi_div_two_le_arcsin _) (arcsin_le_pi_div_two _)
910
911 lemma cos_arcsin {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : cos (arcsin x) = sqrt (1 - x ^ 2) :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ └┘ ┴ ┴ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
doc └┘ ┴
912 have sin (arcsin x) ^ 2 + cos (arcsin x) ^ 2 = 1 := sin_sq_add_cos_sq (arcsin x),
id └─┘ └┘ ┴ └┘ └┘ └┘ ┴ └┘ └┘ ┴
src └─┘ └┘ └┘ └┘ └┘ └┘ └┘
typ └─┘ └┘ ┴ └┘ └┘ └┘ ┴ └┘ └┘ ┴
doc └┘ └┘ └┘ └┘ └┘
913 begin
914 rw [← eq_sub_iff_add_eq', ← sqrt_inj (pow_two_nonneg _) (sub_nonneg.2 (sin_sq_le_one (arcsin x))),
915 pow_two, sqrt_mul_self (cos_arcsin_nonneg _)] at this,
916 rw [this, sin_arcsin hx₁ hx₂],
st ┴
917 end
st └─┘
918
919 lemma sin_arccos {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : sin (arccos x) = sqrt (1 - x ^ 2) :=
id ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ └┘ ┴ ┴ ┴
typ ┴ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
doc └┘ ┴
920 by rw [arccos_eq_pi_div_two_sub_arcsin, sin_pi_div_two_sub, cos_arcsin hx₁ hx₂]
st ┴
921
922 lemma abs_div_sqrt_one_add_lt (x : ℝ) : abs (x / sqrt (1 + x ^ 2)) < 1 :=
id ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ └┘ ┴
923 have h₁ : 0 < 1 + x ^ 2, from add_pos_of_pos_of_nonneg zero_lt_one (pow_two_nonneg _),
id ┴
typ ┴
924 have h₂ : 0 < sqrt (1 + x ^ 2), from sqrt_pos.2 h₁,
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
925 by rw [abs_div, div_lt_iff (abs_pos_of_pos h₂), one_mul,
926 mul_self_lt_mul_self_iff (abs_nonneg x) (abs_nonneg _),
id ┴
typ ┴
927 ← abs_mul, ← abs_mul, mul_self_sqrt (add_nonneg zero_le_one (pow_two_nonneg _)),
928 abs_of_nonneg (mul_self_nonneg x), abs_of_nonneg (le_of_lt h₁), pow_two, add_comm];
id ┴
typ ┴
929 exact lt_add_one _
930
931 lemma div_sqrt_one_add_lt_one (x : ℝ) : x / sqrt (1 + x ^ 2) < 1 :=
id ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ └┘ ┴
932 (abs_lt.1 (abs_div_sqrt_one_add_lt _)).2
933
934 lemma neg_one_lt_div_sqrt_one_add (x : ℝ) : -1 < x / sqrt (1 + x ^ 2) :=
id ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ └┘ ┴
935 (abs_lt.1 (abs_div_sqrt_one_add_lt _)).1
936
937 lemma tan_pos_of_pos_of_lt_pi_div_two {x : ℝ} (h0x : 0 < x) (hxp : x < π / 2) : 0 < tan x :=
id ┴ ┴ ┴ ┴ └┘ ┴
src ┴ ┴ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴
doc ┴
938 by rw tan_eq_sin_div_cos; exact div_pos (sin_pos_of_pos_of_lt_pi h0x (by linarith))
939 (cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two (by linarith) hxp)
940
941 lemma tan_nonneg_of_nonneg_of_le_pi_div_two {x : ℝ} (h0x : 0 ≤ x) (hxp : x ≤ π / 2) : 0 ≤ tan x :=
id ┴ ┴ ┴ ┴ └┘ ┴
src ┴ ┴ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴
doc ┴
942 match lt_or_eq_of_le h0x, lt_or_eq_of_le hxp with
943 | or.inl hx0, or.inl hxp := le_of_lt (tan_pos_of_pos_of_lt_pi_div_two hx0 hxp)
944 | or.inl hx0, or.inr hxp := by simp [hxp, tan_eq_sin_div_cos]
945 | or.inr hx0, _ := by simp [hx0.symm]
946 end
947
948 lemma tan_neg_of_neg_of_pi_div_two_lt {x : ℝ} (hx0 : x < 0) (hpx : -(π / 2) < x) : tan x < 0 :=
id ┴ ┴ ┴ └┘ ┴
src ┴ ┴ └┘
typ ┴ ┴ ┴ └┘ ┴
doc ┴
949 neg_pos.1 (tan_neg x ▸ tan_pos_of_pos_of_lt_pi_div_two (by linarith) (by linarith [pi_pos]))
id ┴
typ ┴
950
951 lemma tan_nonpos_of_nonpos_of_neg_pi_div_two_le {x : ℝ} (hx0 : x ≤ 0) (hpx : -(π / 2) ≤ x) : tan x ≤ 0 :=
id ┴ ┴ ┴ └┘ ┴
src ┴ ┴ └┘
typ ┴ ┴ ┴ └┘ ┴
doc ┴
952 neg_nonneg.1 (tan_neg x ▸ tan_nonneg_of_nonneg_of_le_pi_div_two (by linarith) (by linarith [pi_pos]))
id ┴
typ ┴
953
954 lemma tan_lt_tan_of_nonneg_of_lt_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x < π / 2) (hy₁ : 0 ≤ y)
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
doc ┴
955 (hy₂ : y < π / 2) (hxy : x < y) : tan x < tan y :=
id ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
src ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
doc ┴
956 begin
957 rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos],
958 exact div_lt_div
959 (sin_lt_sin_of_le_of_le_pi_div_two (by linarith) (le_of_lt hx₂)
960 (by linarith) (le_of_lt hy₂) hxy)
961 (cos_le_cos_of_nonneg_of_le_pi hx₁ (by linarith) hy₁ (by linarith) (le_of_lt hxy))
962 (sin_nonneg_of_nonneg_of_le_pi hy₁ (by linarith))
963 (cos_pos_of_neg_pi_div_two_lt_of_lt_pi_div_two (by linarith) hy₂)
964 end
st └─┘
965
966 lemma tan_lt_tan_of_lt_of_lt_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2)
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
967 (hy₁ : -(π / 2) < y) (hy₂ : y < π / 2) (hxy : x < y) : tan x < tan y :=
id ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴
doc ┴ ┴
968 match le_total x 0, le_total y 0 with
id ┴ ┴
typ ┴ ┴
969 | or.inl hx0, or.inl hy0 := neg_lt_neg_iff.1 $ by rw [← tan_neg, ← tan_neg]; exact
970 tan_lt_tan_of_nonneg_of_lt_pi_div_two (neg_nonneg.2 hy0) (neg_lt.2 hy₁)
971 (neg_nonneg.2 hx0) (neg_lt.2 hx₁) (neg_lt_neg hxy)
id └─┘
typ └─┘
972 | or.inl hx0, or.inr hy0 := (lt_or_eq_of_le hy0).elim
973 (λ hy0, calc tan x ≤ 0 : tan_nonpos_of_nonpos_of_neg_pi_div_two_le hx0 (le_of_lt hx₁)
id └─┘ ┴
src └─┘
typ └─┘ ┴
974 ... < tan y : tan_pos_of_pos_of_lt_pi_div_two hy0 hy₂)
id └─┘ ┴
src └─┘
typ └─┘ ┴
975 (λ hy0, by rw [← hy0, tan_zero]; exact
976 tan_neg_of_neg_of_pi_div_two_lt (hy0.symm ▸ hxy) hx₁)
id └─┘
typ └─┘
977 | or.inr hx0, or.inl hy0 := by linarith
978 | or.inr hx0, or.inr hy0 := tan_lt_tan_of_nonneg_of_lt_pi_div_two hx0 hx₂ hy0 hy₂ hxy
id └─┘
typ └─┘
979 end
980
981 lemma tan_inj_of_lt_of_lt_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2)
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
doc ┴ ┴
982 (hy₁ : -(π / 2) < y) (hy₂ : y < π / 2) (hxy : tan x = tan y) : x = y :=
id ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴ └┘ ┴ ┴ ┴
doc ┴ ┴
983 match lt_trichotomy x y with
id ┴ ┴
typ ┴ ┴
984 | or.inl h := absurd (tan_lt_tan_of_lt_of_lt_pi_div_two hx₁ hx₂ hy₁ hy₂ h) (by rw hxy; exact lt_irrefl _)
985 | or.inr (or.inl h) := h
id ┴
typ ┴
986 | or.inr (or.inr h) := absurd (tan_lt_tan_of_lt_of_lt_pi_div_two hy₁ hy₂ hx₁ hx₂ h) (by rw hxy; exact lt_irrefl _)
987 end
988
989 /-- Inverse of the `tan` function, returns values in the range `-π / 2 < arctan x` and `arctan x < π / 2` -/
990 noncomputable def arctan (x : ℝ) : ℝ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
991 arcsin (x / sqrt (1 + x ^ 2))
id ┴ └┘ ┴ └┘ ┴
src ┴ └┘ └┘
typ ┴ └┘ ┴ └┘ ┴
doc ┴ └┘
992
993 lemma sin_arctan (x : ℝ) : sin (arctan x) = x / sqrt (1 + x ^ 2) :=
id ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ └┘ └┘ ┴ ┴
typ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴ ┴
doc └┘ └┘
994 sin_arcsin (le_of_lt (neg_one_lt_div_sqrt_one_add _)) (le_of_lt (div_sqrt_one_add_lt_one _))
995
996 lemma cos_arctan (x : ℝ) : cos (arctan x) = 1 / sqrt (1 + x ^ 2) :=
id ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴
src ┴ ┴ └┘ └┘ ┴ ┴
typ ┴ ┴ └┘ └┘ ┴ ┴ ┴ ┴
doc └┘ └┘
997 have h₁ : (0 : ℝ) < 1 + x ^ 2,
id ┴ ┴
src ┴
typ ┴ ┴
998 from add_pos_of_pos_of_nonneg zero_lt_one (pow_two_nonneg _),
999 have h₂ : (x / sqrt (1 + x ^ 2)) ^ 2 < 1,
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
1000 by rw [pow_two, ← abs_mul_self, _root_.abs_mul];
1001 exact mul_lt_one_of_nonneg_of_lt_one_left (abs_nonneg _)
1002 (abs_div_sqrt_one_add_lt _) (le_of_lt (abs_div_sqrt_one_add_lt _)),
1003 by rw [arctan, cos_arcsin (le_of_lt (neg_one_lt_div_sqrt_one_add _)) (le_of_lt (div_sqrt_one_add_lt_one _)),
1004 one_div_eq_inv, ← sqrt_inv, sqrt_inj (sub_nonneg.2 (le_of_lt h₂)) (inv_nonneg.2 (le_of_lt h₁)),
1005 div_pow _ (mt sqrt_eq_zero'.1 (not_le.2 h₁)), pow_two (sqrt _), mul_self_sqrt (le_of_lt h₁),
id └──┘
src └──┘
typ └──┘
1006 ← domain.mul_left_inj (ne.symm (ne_of_lt h₁)), mul_sub,
1007 mul_div_cancel' _ (ne.symm (ne_of_lt h₁)), mul_inv_cancel (ne.symm (ne_of_lt h₁))];
1008 simp
1009
1010 lemma tan_arctan (x : ℝ) : tan (arctan x) = x :=
id ┴ └┘ └┘ ┴ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ └┘ └┘ ┴ ┴ ┴
doc └┘ ┴
1011 by rw [tan_eq_sin_div_cos, sin_arctan, cos_arctan, div_div_div_div_eq, mul_one,
1012 mul_div_assoc,
1013 div_self (mt sqrt_eq_zero'.1 (not_le_of_gt (add_pos_of_pos_of_nonneg zero_lt_one (pow_two_nonneg x)))),
id ┴
typ ┴
1014 mul_one]
st ┴
1015
1016 lemma arctan_lt_pi_div_two (x : ℝ) : arctan x < π / 2 :=
id ┴ └┘ └┘ ┴ ┴
src ┴ └┘ └┘ ┴
typ ┴ └┘ └┘ ┴ ┴
doc └┘ └┘ ┴
1017 lt_of_le_of_ne (arcsin_le_pi_div_two _)
1018 (λ h, ne_of_lt (div_sqrt_one_add_lt_one x) $
id ┴
typ ┴
1019 by rw [← sin_arcsin (le_of_lt (neg_one_lt_div_sqrt_one_add _))
1020 (le_of_lt (div_sqrt_one_add_lt_one _)), ← arctan, h, sin_pi_div_two])
st ┴
1021
1022 lemma neg_pi_div_two_lt_arctan (x : ℝ) : -(π / 2) < arctan x :=
id ┴ ┴ └┘ └┘ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ └┘ └┘ ┴
doc ┴ └┘ └┘
1023 lt_of_le_of_ne (neg_pi_div_two_le_arcsin _)
1024 (λ h, ne_of_lt (neg_one_lt_div_sqrt_one_add x) $
id ┴
typ ┴
1025 by rw [← sin_arcsin (le_of_lt (neg_one_lt_div_sqrt_one_add _))
1026 (le_of_lt (div_sqrt_one_add_lt_one _)), ← arctan, ← h, sin_neg, sin_pi_div_two])
st ┴
1027
1028 lemma tan_surjective : function.surjective tan :=
id └┘
src └┘
typ └┘
1029 function.surjective_of_has_right_inverse ⟨_, tan_arctan⟩
1030
1031 lemma arctan_tan {x : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2) : arctan (tan x) = x :=
id ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ └┘ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
doc ┴ ┴ └┘ ┴
1032 tan_inj_of_lt_of_lt_pi_div_two (neg_pi_div_two_lt_arctan _)
1033 (arctan_lt_pi_div_two _) hx₁ hx₂ (by rw tan_arctan)
1034
1035 @[simp] lemma arctan_zero : arctan 0 = 0 :=
id └┘ └┘
src └┘ └┘
typ └┘ └┘
doc └──┘ └┘ └┘
1036 by simp [arctan]
id └────┘
src └────┘
typ └────┘
doc └────┘
1037
1038 @[simp] lemma arctan_neg (x : ℝ) : arctan (-x) = - arctan x :=
id ┴ └┘ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ └┘ ┴ └┘
typ ┴ └┘ └┘ ┴ ┴ └┘ ┴
doc └──┘ └┘ └┘ ┴ └┘
1039 by simp [arctan, neg_div]
id └────┘
src └────┘
typ └────┘
doc └────┘
1040
1041 end real
1042
1043 namespace complex
1044
1045 open_locale real
1046
1047 /-- `arg` returns values in the range (-π, π], such that for `x ≠ 0`,
1048 `sin (arg x) = x.im / x.abs` and `cos (arg x) = x.re / x.abs`,
1049 `arg 0` defaults to `0` -/
1050 noncomputable def arg (x : ℂ) : ℝ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
1051 if 0 ≤ x.re
id ┴└┘
src └┘
typ ┴└┘
1052 then real.arcsin (x.im / x.abs)
id └─┘ └┘ └┘ ┴└┘ ┴└──┘
src └─┘ └┘ └┘ └┘ └──┘
typ └─┘ └┘ └┘ ┴└┘ ┴└──┘
doc └─┘ └┘ └┘
1053 else if 0 ≤ x.im
id ┴ └┘
src └┘
typ ┴ └┘
1054 then real.arcsin ((-x).im / x.abs) + π
id └┘ └┘ ┴ ┴ └┘ ┴└┘ ┴ ┴
src └┘ └┘ ┴ └┘ └┘ ┴ ┴
typ └┘ └┘ ┴ ┴ └┘ ┴└┘ ┴ ┴
doc └┘ └┘ ┴ ┴
1055 else real.arcsin ((-x).im / x.abs) - π
id └┘ └┘ └┘ ┴ └┘ ┴ └─┘ ┴
src └┘ └┘ └┘ └┘ └─┘ ┴
typ └┘ └┘ └┘ ┴ └┘ ┴ └─┘ ┴
doc └┘ └┘ └┘ ┴
1056
1057 lemma arg_le_pi (x : ℂ) : arg x ≤ π :=
id ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴ ┴
1058 if hx₁ : 0 ≤ x.re
id ┴ └┘
src └┘
typ ┴ └┘
1059 then by rw [arg, if_pos hx₁];
1060 exact le_trans (real.arcsin_le_pi_div_two _) (le_of_lt (half_lt_self real.pi_pos))
1061 else
1062 have hx : x ≠ 0, from λ h, by simpa [h, lt_irrefl] using hx₁,
id ┴
typ ┴
1063 if hx₂ : 0 ≤ x.im
id ┴└─┘
src └─┘
typ ┴└─┘
1064 then by rw [arg, if_neg hx₁, if_pos hx₂];
1065 exact le_sub_iff_add_le.1 (by rw sub_self;
1066 exact real.arcsin_nonpos (by rw [neg_im, neg_div, neg_nonpos]; exact div_nonneg hx₂ (abs_pos.2 hx)))
1067 else by rw [arg, if_neg hx₁, if_neg hx₂];
1068 exact sub_le_iff_le_add.2 (le_trans (real.arcsin_le_pi_div_two _)
1069 (by linarith [real.pi_pos]))
1070
1071 lemma neg_pi_lt_arg (x : ℂ) : -π < arg x :=
id ┴ ┴ └┘ ┴
src ┴ ┴ └┘
typ ┴ ┴ └┘ ┴
doc ┴ └┘
1072 if hx₁ : 0 ≤ x.re
id ┴ └┘
src └┘
typ ┴ └┘
1073 then by rw [arg, if_pos hx₁];
1074 exact lt_of_lt_of_le (neg_lt_neg (half_lt_self real.pi_pos)) (real.neg_pi_div_two_le_arcsin _)
1075 else
1076 have hx : x ≠ 0, from λ h, by simpa [h, lt_irrefl] using hx₁,
id ┴
typ ┴
1077 if hx₂ : 0 ≤ x.im
id ┴└─┘
src └─┘
typ ┴└─┘
1078 then by rw [arg, if_neg hx₁, if_pos hx₂];
1079 exact sub_lt_iff_lt_add.1
1080 (lt_of_lt_of_le (by linarith [real.pi_pos]) (real.neg_pi_div_two_le_arcsin _))
1081 else by rw [arg, if_neg hx₁, if_neg hx₂];
1082 exact lt_sub_iff_add_lt.2 (by rw neg_add_self;
1083 exact real.arcsin_pos (by rw [neg_im]; exact div_pos (neg_pos.2 (lt_of_not_ge hx₂))
1084 (abs_pos.2 hx)) (by rw [← abs_neg x]; exact (abs_le.1 (abs_im_div_abs_le_one _)).2))
id ┴
typ ┴
1085
1086 lemma arg_eq_arg_neg_add_pi_of_im_nonneg_of_re_neg {x : ℂ} (hxr : x.re < 0) (hxi : 0 ≤ x.im) :
id ┴ ┴└─┘ ┴└┘
src ┴ └─┘ └┘
typ ┴ ┴└─┘ ┴└┘
1087 arg x = arg (-x) + π :=
id └┘ ┴ ┴ ┴ ┴
src └┘ ┴ ┴
typ └┘ ┴ ┴ ┴ ┴
doc └┘ ┴ ┴
1088 have 0 ≤ (-x).re, from le_of_lt $ by simpa [neg_pos],
id ┴ └┘
src └┘
typ ┴ └┘
1089 by rw [arg, arg, if_neg (not_le.2 hxr), if_pos this, if_pos hxi, abs_neg]
st ┴
1090
1091 lemma arg_eq_arg_neg_sub_pi_of_im_neg_of_re_neg {x : ℂ} (hxr : x.re < 0) (hxi : x.im < 0) :
id ┴ ┴└─┘ ┴└┘
src ┴ └─┘ └┘
typ ┴ ┴└─┘ ┴└┘
1092 arg x = arg (-x) - π :=
id └┘ ┴ ┴ ┴ ┴
src └┘ ┴ ┴
typ └┘ ┴ ┴ ┴ ┴
doc └┘ ┴ ┴
1093 have 0 ≤ (-x).re, from le_of_lt $ by simpa [neg_pos],
id ┴ └┘
src └┘
typ ┴ └┘
1094 by rw [arg, arg, if_neg (not_le.2 hxr), if_neg (not_le.2 hxi), if_pos this, abs_neg]
st ┴
1095
1096 @[simp] lemma arg_zero : arg 0 = 0 :=
id └┘
src └┘
typ └┘
doc └──┘ └┘
1097 by simp [arg, le_refl]
id └─┘
src └─┘
typ └─┘
doc └─┘
1098
1099 @[simp] lemma arg_one : arg 1 = 0 :=
id └┘
src └┘
typ └┘
doc └──┘ └┘
1100 by simp [arg, zero_le_one]
id └─┘
src └─┘
typ └─┘
doc └─┘
1101
1102 @[simp] lemma arg_neg_one : arg (-1) = π :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ └┘ ┴
1103 by simp [arg, le_refl, not_le.2 (@zero_lt_one ℝ _)]
id └─┘
src └─┘
typ └─┘
doc └─┘
1104
1105 @[simp] lemma arg_I : arg I = π / 2 :=
id └┘ ┴ ┴
src └┘ ┴ ┴
typ └┘ ┴ ┴
doc └──┘ └┘ ┴
1106 by simp [arg, le_refl]
id └─┘
src └─┘
typ └─┘
doc └─┘
1107
1108 @[simp] lemma arg_neg_I : arg (-I) = -(π / 2) :=
id └┘ ┴ ┴
src └┘ ┴ ┴
typ └┘ ┴ ┴
doc └──┘ └┘ ┴
1109 by simp [arg, le_refl]
id └─┘
src └─┘
typ └─┘
doc └─┘
1110
1111 lemma sin_arg (x : ℂ) : real.sin (arg x) = x.im / x.abs :=
id ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└──┘
src ┴ └┘ └┘ └┘ └─┘ └──┘
typ ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└──┘
doc └┘
1112 by unfold arg; split_ifs;
1113 simp [arg, real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1
id └─┘
src └─┘
typ └─┘
doc └─┘
1114 (abs_le.1 (abs_im_div_abs_le_one x)).2, real.sin_add, neg_div, real.arcsin_neg,
id ┴
typ ┴
1115 real.sin_neg]
1116
1117 private lemma cos_arg_of_re_nonneg {x : ℂ} (hx : x ≠ 0) (hxr : 0 ≤ x.re) : real.cos (arg x) = x.re / x.abs :=
id ┴ ┴ ┴└─┘ ┴ └┘ ┴ ┴ ┴ ┴└─┘ ┴└┘ ┴
src ┴ └─┘ ┴ └┘ ┴ ┴ └─┘ └┘ ┴
typ ┴ ┴ ┴└─┘ ┴ └┘ ┴ ┴ ┴ ┴└─┘ ┴└┘ ┴
doc ┴
1118 have 0 ≤ 1 - (x.im / abs x) ^ 2,
id ┴└─┘ ┴ ┴
src └─┘ ┴
typ ┴└─┘ ┴ ┴
1119 from sub_nonneg.2 $ by rw [pow_two, ← _root_.abs_mul_self, _root_.abs_mul, ← pow_two];
1120 exact pow_le_one _ (_root_.abs_nonneg _) (abs_im_div_abs_le_one _),
1121 by rw [eq_div_iff_mul_eq _ _ (mt abs_eq_zero.1 hx), ← real.mul_self_sqrt (abs_nonneg x),
id ┴
typ ┴
1122 arg, if_pos hxr, real.cos_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1
1123 (abs_le.1 (abs_im_div_abs_le_one x)).2, ← real.sqrt_mul (abs_nonneg _), ← real.sqrt_mul this,
id ┴
typ ┴
1124 sub_mul, div_pow _ (mt abs_eq_zero.1 hx), ← pow_two, div_mul_cancel _ (pow_ne_zero 2 (mt abs_eq_zero.1 hx)),
1125 one_mul, pow_two, mul_self_abs, norm_sq, pow_two, add_sub_cancel, real.sqrt_mul_self hxr]
st ┴
1126
1127 lemma cos_arg {x : ℂ} (hx : x ≠ 0) : real.cos (arg x) = x.re / x.abs :=
id ┴ ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└┘ ┴
src ┴ └┘ └┘ └┘ └─┘ └┘ ┴
typ ┴ ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└┘ ┴
doc └┘
1128 if hxr : 0 ≤ x.re then cos_arg_of_re_nonneg hx hxr
id ┴ └┘
src └┘
typ ┴ └┘
1129 else
1130 have 0 ≤ (-x).re, from le_of_lt $ by simpa [neg_pos] using hxr,
id ┴ └┘
src └┘
typ ┴ └┘
1131 if hxi : 0 ≤ x.im
id ┴└─┘
src └─┘
typ ┴└─┘
1132 then have 0 ≤ (-x).re, from le_of_lt $ by simpa [neg_pos] using hxr,
id ┴ └┘
src └┘
typ ┴ └┘
1133 by rw [arg_eq_arg_neg_add_pi_of_im_nonneg_of_re_neg (not_le.1 hxr) hxi, real.cos_add_pi,
1134 cos_arg_of_re_nonneg (neg_ne_zero.2 hx) this];
1135 simp [neg_div]
1136 else by rw [arg_eq_arg_neg_sub_pi_of_im_neg_of_re_neg (not_le.1 hxr) (not_le.1 hxi)];
1137 simp [real.cos_add, neg_div, cos_arg_of_re_nonneg (neg_ne_zero.2 hx) this]
1138
1139 lemma tan_arg {x : ℂ} : real.tan (arg x) = x.im / x.re :=
id ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└─┘
src ┴ └┘ └┘ └┘ └─┘ └─┘
typ ┴ └┘ └┘ └┘ ┴ ┴└─┘ ┴└─┘
doc └┘
1140 if hx : x = 0 then by simp [hx]
id ┴
typ ┴
1141 else by rw [real.tan_eq_sin_div_cos, sin_arg, cos_arg hx,
1142 div_div_div_cancel_right _ _ (mt abs_eq_zero.1 hx)]
st ┴
1143
1144 lemma arg_cos_add_sin_mul_I {x : ℝ} (hx₁ : -π < x) (hx₂ : x ≤ π) :
id ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴ ┴
1145 arg (cos x + sin x * I) = x :=
id └┘ └┘ ┴ ┴ ┴ ┴ ┴
src └┘ └┘ ┴ ┴
typ └┘ └┘ ┴ ┴ ┴ ┴ ┴
doc └┘
1146 if hx₃ : -(π / 2) ≤ x ∧ x ≤ π / 2
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴ ┴
1147 then
1148 have hx₄ : 0 ≤ (cos x + sin x * I).re,
id └┘ ┴ └┘ ┴ ┴ └┘
src └┘ └┘ ┴ └┘
typ └┘ ┴ └┘ ┴ ┴ └┘
1149 by simp; exact real.cos_nonneg_of_neg_pi_div_two_le_of_le_pi_div_two hx₃.1 hx₃.2,
1150 by rw [arg, if_pos hx₄];
1151 simp [abs_cos_add_sin_mul_I, sin_of_real_re, real.arcsin_sin hx₃.1 hx₃.2]
1152 else if hx₄ : x < -(π / 2)
id ┴ ┴
src ┴
typ ┴ ┴
doc ┴
1153 then
1154 have hx₅ : ¬0 ≤ (cos x + sin x * I).re :=
id ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
src ┴ └─┘ └─┘ ┴ └┘
typ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
1155 suffices ¬ 0 ≤ real.cos x, by simpa,
id ┴ └──────┘ ┴
src ┴ └──────┘
typ ┴ └──────┘ ┴
1156 not_le.2 $ by rw ← real.cos_neg;
1157 apply real.cos_neg_of_pi_div_two_lt_of_lt; linarith,
1158 have hx₆ : ¬0 ≤ (cos ↑x + sin ↑x * I).im :=
id ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
src ┴ └─┘ └─┘ ┴ └┘
typ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
1159 suffices real.sin x < 0, by simpa,
id └──────┘ ┴
src └──────┘
typ └──────┘ ┴
1160 by apply real.sin_neg_of_neg_of_neg_pi_lt; linarith,
1161 suffices -π + -real.arcsin (real.sin x) = x,
id ┴ └─────────┘ └──────┘ ┴ ┴
src ┴ └─────────┘ └──────┘
typ ┴ └─────────┘ └──────┘ ┴ ┴
doc ┴ └─────────┘
1162 by rw [arg, if_neg hx₅, if_neg hx₆];
1163 simpa [abs_cos_add_sin_mul_I, sin_of_real_re],
1164 by rw [← real.arcsin_neg, ← real.sin_add_pi, real.arcsin_sin]; simp; linarith
1165 else
1166 have hx₅ : π / 2 < x, by cases not_and_distrib.1 hx₃; linarith,
id ┴ ┴
src ┴
typ ┴ ┴
doc ┴
1167 have hx₆ : ¬0 ≤ (cos x + sin x * I).re :=
id ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
src ┴ └─┘ └─┘ ┴ └┘
typ ┴ └─┘ ┴ └─┘ ┴ ┴ └┘
1168 suffices ¬0 ≤ real.cos x, by simpa,
id ┴ └──────┘ ┴
src ┴ └──────┘
typ ┴ └──────┘ ┴
1169 not_le.2 $ by apply real.cos_neg_of_pi_div_two_lt_of_lt; linarith,
1170 have hx₇ : 0 ≤ (cos x + sin x * I).im :=
id └─┘ ┴ └─┘ ┴ ┴ └┘
src └─┘ └─┘ ┴ └┘
typ └─┘ ┴ └─┘ ┴ ┴ └┘
1171 suffices 0 ≤ real.sin x, by simpa,
id └──────┘ ┴
src └──────┘
typ └──────┘ ┴
1172 by apply real.sin_nonneg_of_nonneg_of_le_pi; linarith,
1173 suffices π - real.arcsin (real.sin x) = x,
id ┴ └─────────┘ └──────┘ ┴ ┴
src ┴ └─────────┘ └──────┘
typ ┴ └─────────┘ └──────┘ ┴ ┴
doc ┴ └─────────┘
1174 by rw [arg, if_neg hx₆, if_pos hx₇];
1175 simpa [abs_cos_add_sin_mul_I, sin_of_real_re],
1176 by rw [← real.sin_pi_sub, real.arcsin_sin]; simp; linarith
1177
1178 lemma arg_eq_arg_iff {x y : ℂ} (hx : x ≠ 0) (hy : y ≠ 0) :
id ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴
1179 arg x = arg y ↔ (abs y / abs x : ℂ) * x = y :=
id └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
src └┘ ┴ ┴ ┴ └┘ ┴
typ └┘ ┴ ┴ ┴ ┴ ┴ ┴ └┘ ┴ ┴ ┴ ┴
doc └┘ ┴
1180 have hax : abs x ≠ 0, from (mt abs_eq_zero.1 hx),
id ┴ ┴
src ┴
typ ┴ ┴
1181 have hay : abs y ≠ 0, from (mt abs_eq_zero.1 hy),
id ┴ ┴
src ┴
typ ┴ ┴
1182 ⟨λ h,
1183 begin
1184 have hcos := congr_arg real.cos h,
id └──────┘
src └──────┘
typ └──────┘
1185 rw [cos_arg hx, cos_arg hy, div_eq_div_iff hax hay] at hcos,
1186 have hsin := congr_arg real.sin h,
id └──────┘
src └──────┘
typ └──────┘
1187 rw [sin_arg, sin_arg, div_eq_div_iff hax hay] at hsin,
1188 apply complex.ext,
1189 { rw [mul_re, ← of_real_div, of_real_re, of_real_im, zero_mul, sub_zero, mul_comm,
1190 ← mul_div_assoc, hcos, mul_div_cancel _ hax] },
st ┴ └┘
1191 { rw [mul_im, ← of_real_div, of_real_re, of_real_im, zero_mul, add_zero,
1192 mul_comm, ← mul_div_assoc, hsin, mul_div_cancel _ hax] }
st ┴ └┘
1193 end,
st └─┘
1194 λ h,
1195 have hre : abs (y / x) * x.re = y.re,
id └─┘ ┴ ┴ ┴└─┘ ┴└─┘
src └─┘ └─┘ └─┘
typ └─┘ ┴ ┴ ┴└─┘ ┴└─┘
1196 by rw ← of_real_div at h;
1197 simpa [-of_real_div] using congr_arg re h,
id └┘
src └┘
typ └┘
1198 have hre' : abs (x / y) * y.re = x.re,
id └─┘ ┴ ┴ ┴└─┘ ┴└─┘
src └─┘ └─┘ └─┘
typ └─┘ ┴ ┴ ┴└─┘ ┴└─┘
1199 by rw [← hre, abs_div, abs_div, ← mul_assoc, div_mul_div,
1200 mul_comm (abs _), div_self (mul_ne_zero hay hax), one_mul],
id └─┘
src └─┘
typ └─┘
st ┴
1201 have him : abs (y / x) * x.im = y.im,
id └─┘ ┴ ┴ ┴└─┘ ┴└─┘
src └─┘ └─┘ └─┘
typ └─┘ ┴ ┴ ┴└─┘ ┴└─┘
1202 by rw ← of_real_div at h;
1203 simpa [-of_real_div] using congr_arg im h,
id └┘
src └┘
typ └┘
1204 have him' : abs (x / y) * y.im = x.im,
id └─┘ ┴ ┴ ┴└─┘ ┴└─┘
src └─┘ └─┘ └─┘
typ └─┘ ┴ ┴ ┴└─┘ ┴└─┘
1205 by rw [← him, abs_div, abs_div, ← mul_assoc, div_mul_div,
1206 mul_comm (abs _), div_self (mul_ne_zero hay hax), one_mul],
id └─┘
src └─┘
typ └─┘
st ┴
1207 have hxya : x.im / abs x = y.im / abs y,
id ┴└─┘ └─┘ ┴ ┴└─┘ └─┘ ┴
src └─┘ └─┘ └─┘ └─┘
typ ┴└─┘ └─┘ ┴ ┴└─┘ └─┘ ┴
1208 by rw [← him, abs_div, mul_comm, ← mul_div_comm, mul_div_cancel_left _ hay],
st ┴
1209 have hnxya : (-x).im / abs x = (-y).im / abs y,
id ┴ └┘ └─┘ ┴ ┴ └┘ └─┘ ┴
src └┘ └─┘ └┘ └─┘
typ ┴ └┘ └─┘ ┴ ┴ └┘ └─┘ ┴
1210 by rw [neg_im, neg_im, neg_div, neg_div, hxya],
st ┴
1211 if hxr : 0 ≤ x.re
id ┴└─┘
src └─┘
typ ┴└─┘
1212 then
1213 have hyr : 0 ≤ y.re, from hre ▸ mul_nonneg (abs_nonneg _) hxr,
id ┴└─┘
src └─┘
typ ┴└─┘
1214 by simp [arg, *] at *
id └─┘
src └─┘
typ └─┘
doc └─┘
1215 else
1216 have hyr : ¬ 0 ≤ y.re, from λ hyr, hxr $ hre' ▸ mul_nonneg (abs_nonneg _) hyr,
id ┴ ┴└─┘
src ┴ └─┘
typ ┴ ┴└─┘
1217 if hxi : 0 ≤ x.im
id ┴└─┘
src └─┘
typ ┴└─┘
1218 then
1219 have hyi : 0 ≤ y.im, from him ▸ mul_nonneg (abs_nonneg _) hxi,
id ┴└─┘
src └─┘
typ ┴└─┘
1220 by simp [arg, *] at *
id └─┘
src └─┘
typ └─┘
doc └─┘
1221 else
1222 have hyi : ¬ 0 ≤ y.im, from λ hyi, hxi $ him' ▸ mul_nonneg (abs_nonneg _) hyi,
id ┴ ┴└─┘
src ┴ └─┘
typ ┴ ┴└─┘
1223 by simp [arg, *] at *⟩
id └─┘
src └─┘
typ └─┘
doc └─┘
1224
1225 lemma arg_real_mul (x : ℂ) {r : ℝ} (hr : 0 < r) : arg (r * x) = arg x :=
id ┴ ┴ ┴ └┘ ┴ ┴ └┘ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ ┴ └┘ ┴ ┴ └┘ ┴
doc └┘ └┘
1226 if hx : x = 0 then by simp [hx]
id ┴
typ ┴
1227 else (arg_eq_arg_iff (mul_ne_zero (of_real_ne_zero.2 (ne_of_lt hr).symm) hx) hx).2 $
1228 by rw [abs_mul, abs_of_nonneg (le_of_lt hr), ← mul_assoc,
1229 of_real_mul, mul_comm (r : ℂ), ← div_div_eq_div_mul,
id ┴
typ ┴
1230 div_mul_cancel _ (of_real_ne_zero.2 (ne_of_lt hr).symm),
1231 div_self (of_real_ne_zero.2 (mt abs_eq_zero.1 hx)), one_mul]
st ┴
1232
1233 lemma ext_abs_arg {x y : ℂ} (h₁ : x.abs = y.abs) (h₂ : x.arg = y.arg) : x = y :=
id ┴ ┴└──┘ ┴ └─┘ ┴└┘ ┴ ┴└──┘ ┴ ┴
src ┴ └──┘ └─┘ └┘ ┴ └──┘
typ ┴ ┴└──┘ ┴ └─┘ ┴└┘ ┴ ┴└──┘ ┴ ┴
doc └┘ ┴ └──┘
1234 if hy : y = 0 then by simp * at *
id ┴
typ ┴
1235 else have hx : x ≠ 0, from λ hx, by simp [*, eq_comm] at *,
id ┴
typ ┴
1236 by rwa [arg_eq_arg_iff hx hy, h₁, div_self (of_real_ne_zero.2 (mt abs_eq_zero.1 hy)), one_mul] at h₂
1237
1238 lemma arg_of_real_of_nonneg {x : ℝ} (hx : 0 ≤ x) : arg x = 0 :=
id ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ └┘ ┴
doc └┘
1239 by simp [arg, hx]
id └─┘
src └─┘
typ └─┘
doc └─┘
1240
1241 lemma arg_of_real_of_neg {x : ℝ} (hx : x < 0) : arg x = π :=
id ┴ ┴ └┘ ┴ ┴
src ┴ └┘ ┴
typ ┴ ┴ └┘ ┴ ┴
doc └┘ ┴
1242 by rw [arg_eq_arg_neg_add_pi_of_im_nonneg_of_re_neg, ← of_real_neg, arg_of_real_of_nonneg];
1243 simp [*, le_iff_eq_or_lt, lt_neg]
1244
1245 /-- Inverse of the `exp` function. Returns values such that `(log x).im > - π` and `(log x).im ≤ π`.
1246 `log 0 = 0`-/
1247 noncomputable def log (x : ℂ) : ℂ := x.abs.log + arg x * I
id ┴ ┴ ┴└┘ └──┘ ┴ ┴ ┴
src ┴ ┴ └┘ └──┘ ┴ ┴
typ ┴ ┴ ┴└┘ └──┘ ┴ ┴ ┴
doc └──┘ ┴
1248
1249 lemma log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log]
id ┴ ┴└──┘ ┴ ┴└──┘└┘ └─┘
src ┴ └──┘ ┴ └──┘└┘ └─┘
typ ┴ ┴└──┘ ┴ ┴└──┘└┘ └─┘
doc └──┘ └┘ └─┘
1250
1251 lemma log_im (x : ℂ) : x.log.im = x.arg := by simp [log]
id ┴ ┴└──┘└┘ ┴ └─┘ └─┘
src ┴ └──┘└┘ └─┘ └─┘
typ ┴ ┴└──┘└┘ ┴ └─┘ └─┘
doc └──┘ └─┘ └─┘
1252
1253 lemma exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x :=
id ┴ ┴ └┘ └┘ ┴ ┴
src ┴ └┘ └┘
typ ┴ ┴ └┘ └┘ ┴ ┴
doc └┘
1254 by rw [log, exp_add_mul_I, ← of_real_sin, sin_arg, ← of_real_cos, cos_arg hx,
1255 ← of_real_exp, real.exp_log (abs_pos.2 hx), mul_add, of_real_div, of_real_div,
1256 mul_div_cancel' _ (of_real_ne_zero.2 (mt abs_eq_zero.1 hx)), ← mul_assoc,
1257 mul_div_cancel' _ (of_real_ne_zero.2 (mt abs_eq_zero.1 hx)), re_add_im]
st ┴
1258
1259 lemma exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π)
id ┴ ┴ ┴└─┘ ┴┴ ┴
src ┴ ┴ └─┘ ┴ ┴
typ ┴ ┴ ┴└─┘ ┴┴ ┴
doc ┴ ┴
1260 (hy₁ : - π < y.im) (hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y :=
id ┴ ┴└┘ ┴└─┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴
src ┴ └┘ └─┘ ┴ └┘ └┘
typ ┴ ┴└┘ ┴└─┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴
doc ┴ ┴
1261 by rw [exp_eq_exp_re_mul_sin_add_cos, exp_eq_exp_re_mul_sin_add_cos y] at hxy;
1262 exact complex.ext
1263 (real.exp_injective $
id └────────────────┘
src └────────────────┘
typ └────────────────┘
1264 by simpa [abs_mul, abs_cos_add_sin_mul_I] using congr_arg complex.abs hxy)
id └─────────┘
src └─────────┘
typ └─────────┘
1265 (by simpa [(of_real_exp _).symm, - of_real_exp, arg_real_mul _ (real.exp_pos _),
1266 arg_cos_add_sin_mul_I hx₁ hx₂, arg_cos_add_sin_mul_I hy₁ hy₂] using congr_arg arg hxy)
id └─┘
src └─┘
typ └─┘
doc └─┘
1267
1268 lemma log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂: x.im ≤ π) : log (exp x) = x :=
id ┴ ┴ ┴└─┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴
src ┴ ┴ └─┘ └┘ ┴ └┘ ┴
typ ┴ ┴ ┴└─┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴
doc ┴ ┴ └┘
1269 exp_inj_of_neg_pi_lt_of_le_pi
1270 (by rw log_im; exact neg_pi_lt_arg _)
1271 (by rw log_im; exact arg_le_pi _)
1272 hx₁ hx₂ (by rw [exp_log (exp_ne_zero _)])
st ┴
1273
1274 lemma of_real_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x :=
id ┴ ┴ ┴└──┘ ┴ ┴ ┴
src ┴ └──┘ ┴ ┴
typ ┴ ┴ ┴└──┘ ┴ ┴ ┴
doc └──┘ ┴
1275 complex.ext
1276 (by rw [log_re, of_real_re, abs_of_nonneg hx])
st ┴
1277 (by rw [of_real_im, log_im, arg_of_real_of_nonneg hx])
st ┴
1278
1279 @[simp] lemma log_zero : log 0 = 0 := by simp [log]
id └┘ └─┘
src └┘ └─┘
typ └┘ └─┘
doc └──┘ └┘ └─┘
1280
1281 @[simp] lemma log_one : log 1 = 0 := by simp [log]
id └┘ └─┘
src └┘ └─┘
typ └┘ └─┘
doc └──┘ └┘ └─┘
1282
1283 lemma log_neg_one : log (-1) = π * I := by simp [log]
id └┘ ┴ ┴ └─┘
src └┘ ┴ ┴ └─┘
typ └┘ ┴ ┴ └─┘
doc └┘ ┴ └─┘
1284
1285 lemma log_I : log I = π / 2 * I := by simp [log]
id └┘ ┴ ┴ ┴ └─┘
src └┘ ┴ ┴ ┴ └─┘
typ └┘ ┴ ┴ ┴ └─┘
doc └┘ ┴ └─┘
1286
1287 lemma log_neg_I : log (-I) = -(π / 2) * I := by simp [log]
id └┘ ┴ ┴ ┴ └─┘
src └┘ ┴ ┴ ┴ └─┘
typ └┘ ┴ ┴ ┴ └─┘
doc └┘ ┴ └─┘
1288
1289 lemma exp_eq_one_iff {x : ℂ} : exp x = 1 ↔ ∃ n : ℤ, x = n * ((2 * π) * I) :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ ┴ ┴ ┴ ┴
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴
1290 have real.exp (x.re) * real.cos (x.im) = 1 → real.cos x.im ≠ -1,
id └──┘ ┴└─┘ └┘ └┘ ┴└─┘ ┴ └┘ └┘ ┴ ┴
src └──┘ └─┘ └┘ └┘ └─┘ ┴ └┘ └┘ ┴
typ └──┘ ┴└─┘ └┘ └┘ ┴└─┘ ┴ └┘ └┘ ┴ ┴
1291 from λ h₁ h₂, begin
1292 rw [h₂, mul_neg_eq_neg_mul_symm, mul_one, neg_eq_iff_neg_eq] at h₁,
1293 have := real.exp_pos x.re,
id └──┘
src └──┘
typ └──┘
1294 rw ← h₁ at this,
1295 exact absurd this (by norm_num)
1296 end,
st └─┘
1297 calc exp x = 1 ↔ (exp x).re = 1 ∧ (exp x).im = 0 : by simp [complex.ext_iff]
id ┴ └─┘ ┴ └┘ ┴ └─┘ ┴ └┘
src └─┘ └┘ ┴ └─┘ └┘
typ ┴ └─┘ ┴ └┘ ┴ └─┘ ┴ └┘
1298 ... ↔ real.cos x.im = 1 ∧ real.sin x.im = 0 ∧ x.re = 0 :
id └──────┘ ┴└─┘ └──────┘ ┴└─┘ ┴└─┘
src └──────┘ └─┘ └──────┘ └─┘ └─┘
typ └──────┘ ┴└─┘ └──────┘ ┴└─┘ ┴└─┘
1299 begin
1300 rw exp_eq_exp_re_mul_sin_add_cos,
1301 simp [complex.ext_iff, cos_of_real_re, sin_of_real_re, exp_of_real_re,
1302 real.exp_ne_zero],
1303 split; finish [real.sin_eq_zero_iff_cos_eq]
1304 end
st └─┘
1305 ... ↔ (∃ n : ℤ, ↑n * (2 * π) = x.im) ∧ (∃ n : ℤ, ↑n * π = x.im) ∧ x.re = 0 :
id ┴ ┴ ┴ ┴└─┘ ┴ ┴ ┴ ┴└─┘ ┴└─┘
src ┴ ┴ └─┘ ┴ ┴ └─┘ └─┘
typ ┴ ┴ ┴ ┴└─┘ ┴ ┴ ┴ ┴└─┘ ┴└─┘
doc ┴ ┴
1306 by rw [real.sin_eq_zero_iff, real.cos_eq_one_iff]
st ┴
1307 ... ↔ ∃ n : ℤ, x = n * ((2 * π) * I) :
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
doc ┴
1308 ⟨λ ⟨⟨n, hn⟩, ⟨m, hm⟩, h⟩, ⟨n, by simp [complex.ext_iff, hn.symm, h]⟩,
id ┴
typ ┴
1309 λ ⟨n, hn⟩, ⟨⟨n, by simp [hn]⟩, ⟨2 * n, by simp [hn, mul_comm, mul_assoc, mul_left_comm]⟩,
id ┴
typ ┴
1310 by simp [hn]⟩⟩
1311
1312 lemma exp_eq_exp_iff_exp_sub_eq_one {x y : ℂ} : exp x = exp y ↔ exp (x - y) = 1 :=
id ┴ └┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴
src ┴ └┘ ┴ ┴ └┘
typ ┴ └┘ ┴ ┴ ┴ ┴ └┘ ┴ ┴
1313 by rw [exp_sub, div_eq_one_iff_eq _ (exp_ne_zero _)]
st ┴
1314
1315 lemma exp_eq_exp_iff_exists_int {x y : ℂ} : exp x = exp y ↔ ∃ n : ℤ, x = y + n * ((2 * π) * I) :=
id ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ └┘ ┴ ┴ ┴ ┴ ┴
typ ┴ └┘ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc ┴
1316 by simp only [exp_eq_exp_iff_exp_sub_eq_one, exp_eq_one_iff, sub_eq_iff_eq_add']
1317
1318 @[simp] lemma cos_pi_div_two : cos (π / 2) = 0 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1319 calc cos (π / 2) = real.cos (π / 2) : by rw [of_real_cos]; simp
id └┘ ┴ └┘ └┘ ┴
src └┘ ┴ └┘ └┘ ┴
typ └┘ ┴ └┘ └┘ ┴
doc ┴ ┴
1320 ... = 0 : by simp
1321
1322 @[simp] lemma sin_pi_div_two : sin (π / 2) = 1 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1323 calc sin (π / 2) = real.sin (π / 2) : by rw [of_real_sin]; simp
id └┘ ┴ └┘ └┘ ┴
src └┘ ┴ └┘ └┘ ┴
typ └┘ ┴ └┘ └┘ ┴
doc ┴ ┴
1324 ... = 1 : by simp
1325
1326 @[simp] lemma sin_pi : sin π = 0 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1327 by rw [← of_real_sin, real.sin_pi]; simp
1328
1329 @[simp] lemma cos_pi : cos π = -1 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1330 by rw [← of_real_cos, real.cos_pi]; simp
1331
1332 @[simp] lemma sin_two_pi : sin (2 * π) = 0 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1333 by simp [two_mul, sin_add]
1334
1335 @[simp] lemma cos_two_pi : cos (2 * π) = 1 :=
id └┘ ┴
src └┘ ┴
typ └┘ ┴
doc └──┘ ┴
1336 by simp [two_mul, cos_add]
1337
1338 lemma sin_add_pi (x : ℝ) : sin (x + π) = -sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1339 by simp [sin_add]
1340
1341 lemma sin_add_two_pi (x : ℝ) : sin (x + 2 * π) = sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1342 by simp [sin_add_pi, sin_add, sin_two_pi, cos_two_pi]
1343
1344 lemma cos_add_two_pi (x : ℝ) : cos (x + 2 * π) = cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1345 by simp [cos_add, cos_two_pi, sin_two_pi]
1346
1347 lemma sin_pi_sub (x : ℝ) : sin (π - x) = sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1348 by simp [sin_add]
1349
1350 lemma cos_add_pi (x : ℝ) : cos (x + π) = -cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1351 by simp [cos_add]
1352
1353 lemma cos_pi_sub (x : ℝ) : cos (π - x) = -cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1354 by simp [cos_add]
1355
1356 lemma sin_add_pi_div_two (x : ℝ) : sin (x + π / 2) = cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1357 by simp [sin_add]
1358
1359 lemma sin_sub_pi_div_two (x : ℝ) : sin (x - π / 2) = -cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1360 by simp [sin_add]
1361
1362 lemma sin_pi_div_two_sub (x : ℝ) : sin (π / 2 - x) = cos x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1363 by simp [sin_add]
1364
1365 lemma cos_add_pi_div_two (x : ℝ) : cos (x + π / 2) = -sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1366 by simp [cos_add]
1367
1368 lemma cos_sub_pi_div_two (x : ℝ) : cos (x - π / 2) = sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1369 by simp [cos_add]
1370
1371 lemma cos_pi_div_two_sub (x : ℝ) : cos (π / 2 - x) = sin x :=
id ┴ └┘ ┴ ┴ └┘ ┴
src ┴ └┘ ┴ └┘
typ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴
1372 by rw [← cos_neg, neg_sub, cos_sub_pi_div_two]
st ┴
1373
1374 lemma sin_nat_mul_pi (n : ℕ) : sin (n * π) = 0 :=
id ┴ └┘ ┴ ┴
src ┴ └┘ ┴
typ ┴ └┘ ┴ ┴
doc ┴
1375 by induction n; simp [add_mul, sin_add, *]
1376
1377 lemma sin_int_mul_pi (n : ℤ) : sin (n * π) = 0 :=
id ┴ └┘ ┴ ┴
src ┴ └┘ ┴
typ ┴ └┘ ┴ ┴
doc ┴
1378 by cases n; simp [add_mul, sin_add, *, sin_nat_mul_pi]
1379
1380 lemma cos_nat_mul_two_pi (n : ℕ) : cos (n * (2 * π)) = 1 :=
id ┴ └┘ ┴ ┴
src ┴ └┘ ┴
typ ┴ └┘ ┴ ┴
doc ┴
1381 by induction n; simp [*, mul_add, cos_add, add_mul, cos_two_pi, sin_two_pi]
1382
1383 lemma cos_int_mul_two_pi (n : ℤ) : cos (n * (2 * π)) = 1 :=
id ┴ └┘ ┴ ┴
src ┴ └┘ ┴
typ ┴ └┘ ┴ ┴
doc ┴
1384 by cases n; simp only [cos_nat_mul_two_pi, int.of_nat_eq_coe,
1385 int.neg_succ_of_nat_coe, int.cast_coe_nat, int.cast_neg,
1386 (neg_mul_eq_neg_mul _ _).symm, cos_neg]
1387
1388 lemma cos_int_mul_two_pi_add_pi (n : ℤ) : cos (n * (2 * π) + π) = -1 :=
id ┴ └┘ ┴ ┴ ┴
src ┴ └┘ ┴ ┴
typ ┴ └┘ ┴ ┴ ┴
doc ┴ ┴
1389 by simp [cos_add, sin_add, cos_int_mul_two_pi]
1390
1391 section pow
1392
1393 /-- The complex power function `x^y`, given by `x^y = exp(y log x)` (where `log` is the principal
1394 determination of the logarithm), unless `x = 0` where one sets `0^0 = 1` and `0^y = 0` for
1395 `y ≠ 0`. -/
1396 noncomputable def cpow (x y : ℂ) : ℂ :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
1397 if x = 0
id ┴
typ ┴
1398 then if y = 0
id ┴
typ ┴
1399 then 1
1400 else 0
1401 else exp (log x * y)
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc ┴
1402
1403 noncomputable instance : has_pow ℂ ℂ := ⟨cpow⟩
id ┴ ┴
src ┴ ┴
typ ┴ ┴
1404
1405 lemma cpow_def (x y : ℂ) : x ^ y =
id ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴
1406 if x = 0
id ┴
typ ┴
1407 then if y = 0
id ┴
typ ┴
1408 then 1
1409 else 0
1410 else exp (log x * y) := rfl
id ┴ └┘ ┴ ┴
src ┴ └┘
typ ┴ └┘ ┴ ┴
doc └┘
1411
1412 @[simp] lemma cpow_zero (x : ℂ) : x ^ (0 : ℂ) = 1 := by simp [cpow_def]
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
doc └──┘
1413
1414 @[simp] lemma zero_cpow {x : ℂ} (h : x ≠ 0) : (0 : ℂ) ^ x = 0 :=
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc └──┘
1415 by simp [cpow_def, *]
1416
1417 @[simp] lemma cpow_one (x : ℂ) : x ^ (1 : ℂ) = x :=
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc └──┘
1418 if hx : x = 0 then by simp [hx, cpow_def]
id ┴
typ ┴
1419 else by rw [cpow_def, if_neg (@one_ne_zero ℂ _), if_neg hx, mul_one, exp_log hx]
st ┴
1420
1421 @[simp] lemma one_cpow (x : ℂ) : (1 : ℂ) ^ x = 1 :=
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
doc └──┘
1422 by rw cpow_def; split_ifs; simp [one_ne_zero, *] at *
1423
1424 lemma cpow_add {x : ℂ} (y z : ℂ) (hx : x ≠ 0) : x ^ (y + z) = x ^ y * x ^ z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1425 by simp [cpow_def]; split_ifs; simp [*, exp_add, mul_add] at *
1426
1427 lemma cpow_mul {x y : ℂ} (z : ℂ) (h₁ : -π < (log x * y).im) (h₂ : (log x * y).im ≤ π) :
id ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ └┘ ┴
src ┴ ┴ ┴ └┘ ┴ └┘ └┘ ┴
typ ┴ ┴ ┴ └┘ ┴ ┴ ┴ └┘ ┴ ┴ └┘ ┴
doc ┴ └┘ └┘ ┴
1428 x ^ (y * z) = (x ^ y) ^ z :=
id ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴
1429 begin
1430 simp [cpow_def],
1431 split_ifs;
1432 simp [*, exp_ne_zero, log_exp h₁ h₂, mul_assoc] at *
1433 end
st └─┘
1434
1435 lemma cpow_neg (x y : ℂ) : x ^ -y = (x ^ y)⁻¹ :=
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
1436 by simp [cpow_def]; split_ifs; simp [exp_neg]
1437
1438 @[simp] lemma cpow_nat_cast (x : ℂ) : ∀ (n : ℕ), x ^ (n : ℂ) = x ^ n
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
1439 | 0 := by simp
1440 | (n + 1) := if hx : x = 0 then by simp only [hx, pow_succ,
id ┴
typ ┴
1441 complex.zero_cpow (nat.cast_ne_zero.2 (nat.succ_ne_zero _)), zero_mul]
1442 else by simp [cpow_def, hx, mul_add, exp_add, pow_succ, (cpow_nat_cast n).symm, exp_log hx]
id ┴
typ ┴
1443
1444 @[simp] lemma cpow_int_cast (x : ℂ) : ∀ (n : ℤ), x ^ (n : ℂ) = x ^ n
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
1445 | (n : ℕ) := by simp; refl
id ┴ └──┘
src ┴ └──┘
typ ┴ └──┘
doc └──┘
1446 | -[1+ n] := by rw fpow_neg_succ_of_nat;
id └──┘
src └──┘
typ └──┘
1447 simp only [int.neg_succ_of_nat_coe, int.cast_neg, complex.cpow_neg, inv_eq_one_div,
1448 int.cast_coe_nat, cpow_nat_cast]
1449
1450 lemma cpow_nat_inv_pow (x : ℂ) {n : ℕ} (hn : 0 < n) : (x ^ (n⁻¹ : ℂ)) ^ n = x :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1451 have (log x * (↑n)⁻¹).im = (log x).im / n,
id └┘ ┴ ┴ └┘ └┘ ┴ ┴ ┴
src └┘ └┘ └┘ ┴
typ └┘ ┴ ┴ └┘ └┘ ┴ ┴ ┴
doc └┘ └┘
1452 by rw [div_eq_mul_inv, ← of_real_nat_cast, ← of_real_inv, mul_im,
1453 of_real_re, of_real_im]; simp,
1454 have h : -π < (log x * (↑n)⁻¹).im ∧ (log x * (↑n)⁻¹).im ≤ π,
id ┴ └─┘ ┴ ┴ └┘ ┴ └─┘ ┴ ┴ └┘ ┴
src ┴ └─┘ └┘ ┴ └─┘ └┘ ┴
typ ┴ └─┘ ┴ ┴ └┘ ┴ └─┘ ┴ ┴ └┘ ┴
doc ┴ └─┘ └─┘ ┴
1455 from (le_total (log x).im 0).elim
id └─┘ ┴ └┘
src └─┘ └┘
typ └─┘ ┴ └┘
doc └─┘
1456 (λ h, ⟨calc -π < (log x).im : by simp [log, neg_pi_lt_arg]
id ┴ └─┘ ┴ └┘ └─┘
src ┴ └─┘ └┘ └─┘
typ ┴ └─┘ ┴ └┘ └─┘
doc ┴ └─┘ └─┘
1457 ... ≤ ((log x).im * 1) / n : le_div_of_mul_le (nat.cast_pos.2 hn)
id └─┘ ┴ └┘ ┴
src └─┘ └┘
typ └─┘ ┴ └┘ ┴
doc └─┘
1458 (mul_le_mul_of_nonpos_left (by rw ← nat.cast_one; exact nat.cast_le.2 hn) h)
1459 ... = (log x * (↑n)⁻¹).im : by simp [this],
id └─┘ ┴ ┴ └┘
src └─┘ └┘
typ └─┘ ┴ ┴ └┘
doc └─┘
1460 this.symm ▸ le_trans (div_nonpos_of_nonpos_of_pos h (nat.cast_pos.2 hn))
1461 (le_of_lt real.pi_pos)⟩)
1462 (λ h, ⟨this.symm ▸ lt_of_lt_of_le (neg_neg_of_pos real.pi_pos)
1463 (div_nonneg h (nat.cast_pos.2 hn)),
1464 calc (log x * (↑n)⁻¹).im = (1 * (log x).im) / n : by simp [this]
id └─┘ ┴ ┴ └┘ └─┘ ┴ └┘ ┴
src └─┘ └┘ └─┘ └┘
typ └─┘ ┴ ┴ └┘ └─┘ ┴ └┘ ┴
doc └─┘ └─┘
1465 ... ≤ (log x).im : (div_le_of_le_mul (nat.cast_pos.2 hn)
id └─┘ ┴ └┘
src └─┘ └┘
typ └─┘ ┴ └┘
doc └─┘
1466 (mul_le_mul_of_nonneg_right (by rw ← nat.cast_one; exact nat.cast_le.2 hn) h))
1467 ... ≤ _ : by simp [log, arg_le_pi]⟩),
id └─┘
src └─┘
typ └─┘
doc └─┘
1468 by rw [← cpow_nat_cast, ← cpow_mul _ h.1 h.2,
1469 inv_mul_cancel (show (n : ℂ) ≠ 0, from nat.cast_ne_zero.2 (nat.pos_iff_ne_zero.1 hn)),
id ┴
typ ┴
1470 cpow_one]
st ┴
1471
1472 end pow
1473
1474 end complex
1475
1476 namespace real
1477
1478 /-- The real power function `x^y`, defined as the real part of the complex power function.
1479 For `x > 0`, it is equal to `exp(y log x)`. For `x = 0`, one sets `0^0=1` and `0^y=0` for `y ≠ 0`.
1480 For `x < 0`, the definition is somewhat arbitary as it depends on the choice of a complex
1481 determination of the logarithm. With our conventions, it is equal to `exp (y log (-x)) cos (πy)`. -/
1482 noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re
id ┴ ┴ ┴ ┴ ┴ └┘
src ┴ ┴ ┴ └┘
typ ┴ ┴ ┴ ┴ ┴ └┘
1483
1484 noncomputable instance : has_pow ℝ ℝ := ⟨rpow⟩
id ┴ ┴
src ┴ ┴
typ ┴ ┴
1485
1486 lemma rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
src ┴ ┴ ┴ └┘
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ └┘
1487
1488 lemma rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y =
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1489 if x = 0
id ┴
typ ┴
1490 then if y = 0
id ┴
typ ┴
1491 then 1
1492 else 0
1493 else exp (log x * y) :=
id └┘ ┴ ┴ ┴
src └┘ ┴
typ └┘ ┴ ┴ ┴
doc ┴
1494 by simp only [rpow_def, complex.cpow_def];
1495 split_ifs;
1496 simp [*, (complex.of_real_log hx).symm, -complex.of_real_mul,
1497 (complex.of_real_mul _ _).symm, complex.exp_of_real_re] at *
1498
1499 lemma rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) :=
id ┴ ┴ ┴ ┴ ┴ └┘ └┘ ┴ ┴
src ┴ ┴ └┘ └┘
typ ┴ ┴ ┴ ┴ ┴ └┘ └┘ ┴ ┴
doc └┘
1500 by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
st ┴
1501
1502 open_locale real
1503
1504 lemma rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log (-x) * y) * cos (y * π) :=
id ┴ ┴ ┴ ┴ ┴ └┘ └┘ ┴ ┴ └┘ ┴ ┴
src ┴ ┴ └┘ └┘ └┘ ┴
typ ┴ ┴ ┴ ┴ ┴ └┘ └┘ ┴ ┴ └┘ ┴ ┴
doc └┘ ┴
1505 begin
1506 rw [rpow_def, complex.cpow_def, if_neg],
1507 have : complex.log x * y = ↑(log(-x) * y) + ↑(y * π) * complex.I,
id └─────────┘ └─┘ ┴ ┴ └───────┘
src └─────────┘ └─┘ └───────┘
typ └─────────┘ └─┘ ┴ ┴ └───────┘
doc └─────────┘ └─┘
1508 simp only [complex.log, abs_of_neg hx, complex.arg_of_real_of_neg hx,
id └─────────┘
src └─────────┘
typ └─────────┘
doc └─────────┘
1509 complex.abs_of_real, complex.of_real_mul], ring,
1510 { rw [this, complex.exp_add_mul_I, ← complex.of_real_exp, ← complex.of_real_cos,
1511 ← complex.of_real_sin, mul_add, ← complex.of_real_mul, ← mul_assoc, ← complex.of_real_mul,
1512 complex.add_re, complex.of_real_re, complex.mul_re, complex.I_re, complex.of_real_im], ring },
st └┘
1513 { rw complex.of_real_eq_zero, exact ne_of_lt hx }
st └─
1514 end
st ──┘
1515
1516 lemma rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) : x ^ y =
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1517 if x = 0
id ┴
typ ┴
1518 then if y = 0
id ┴
typ ┴
1519 then 1
1520 else 0
1521 else exp (log (-x) * y) * cos (y * π) :=
id └┘ ┴ ┴ ┴ └┘ ┴ ┴
src └┘ ┴ └┘ ┴
typ └┘ ┴ ┴ ┴ └┘ ┴ ┴
doc ┴ ┴
1522 by split_ifs; simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
1523
1524 lemma rpow_pos_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : 0 < x ^ y :=
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1525 by rw rpow_def_of_pos hx; apply exp_pos
1526
1527 lemma abs_rpow_le_abs_rpow (x y : ℝ) : abs (x ^ y) ≤ abs (x) ^ y :=
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
1528 abs_le_of_le_of_neg_le
1529 begin
1530 cases lt_trichotomy 0 x, { rw abs_of_pos h },
st └┘
1531 cases h, { simp [h.symm] },
st └┘
1532 rw [rpow_def_of_neg h, rpow_def_of_pos (abs_pos_of_neg h), abs_of_neg h],
1533 calc exp (log (-x) * y) * cos (y * π) ≤ exp (log (-x) * y) * 1 :
id └─┘ └─┘ └─┘ ┴ ┴
src └─┘ └─┘ └─┘
typ └─┘ └─┘ └─┘ ┴ ┴
doc └─┘
1534 mul_le_mul_of_nonneg_left (cos_le_one _) (le_of_lt $ exp_pos _)
1535 ... = _ : mul_one _
1536 end
st └─┘
1537 begin
1538 cases lt_trichotomy 0 x, { rw abs_of_pos h, have : 0 < x^y := rpow_pos_of_pos h _, linarith },
id ┴ ┴ ┴
typ ┴ ┴ ┴
st └┘
1539 cases h, { simp only [h.symm, abs_zero, rpow_def_of_nonneg], split_ifs, repeat {norm_num}},
st └─┘
1540 rw [rpow_def_of_neg h, rpow_def_of_pos (abs_pos_of_neg h), abs_of_neg h],
1541 calc -(exp (log (-x) * y) * cos (y * π)) = exp (log (-x) * y) * (-cos (y * π)) : by ring
id ┴ └─┘ ┴
src └─┘
typ ┴ └─┘ ┴
1542 ... ≤ exp (log (-x) * y) * 1 :
1543 mul_le_mul_of_nonneg_left (neg_le.2 $ neg_one_le_cos _) (le_of_lt $ exp_pos _)
1544 ... = exp (log (-x) * y) : mul_one _
1545 end
st └─┘
1546
1547 end real
1548
1549 namespace complex
1550
1551 lemma of_real_cpow {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : ((x ^ y : ℝ) : ℂ) = (x : ℂ) ^ (y : ℂ) :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1552 by simp [real.rpow_def_of_nonneg hx, complex.cpow_def]; split_ifs; simp [complex.of_real_log hx]
1553
1554 @[simp] lemma abs_cpow_real (x : ℂ) (y : ℝ) : abs (x ^ (y : ℂ)) = x.abs ^ y :=
id ┴ ┴ └┘ ┴ ┴ ┴ ┴└──┘ ┴
src ┴ ┴ └┘ ┴ └──┘
typ ┴ ┴ └┘ ┴ ┴ ┴ ┴└──┘ ┴
doc └──┘
1555 begin
1556 rw [real.rpow_def_of_nonneg (abs_nonneg _), complex.cpow_def],
1557 split_ifs;
1558 simp [*, abs_of_nonneg (le_of_lt (real.exp_pos _)), complex.log, complex.exp_add,
1559 add_mul, mul_right_comm _ I, exp_mul_I, abs_cos_add_sin_mul_I,
id ┴
src ┴
typ ┴
1560 (complex.of_real_mul _ _).symm, -complex.of_real_mul] at *
1561 end
st └─┘
1562
1563 @[simp] lemma abs_cpow_inv_nat (x : ℂ) (n : ℕ) : abs (x ^ (n⁻¹ : ℂ)) = x.abs ^ (n⁻¹ : ℝ) :=
id ┴ ┴ └┘ ┴ ┴ ┴ ┴└──┘ ┴
src ┴ ┴ └┘ ┴ └──┘ ┴
typ ┴ ┴ └┘ ┴ ┴ ┴ ┴└──┘ ┴
doc └──┘
1564 by rw ← abs_cpow_real; simp [-abs_cpow_real]
1565
1566 end complex
1567
1568 namespace real
1569
1570 open_locale real
1571
1572 variables {x y z : ℝ}
id ┴
src ┴
typ ┴
1573
1574 @[simp] lemma rpow_zero (x : ℝ) : x ^ (0 : ℝ) = 1 := by simp [rpow_def]
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
doc └──┘
1575
1576 @[simp] lemma zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ) ^ x = 0 :=
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc └──┘
1577 by simp [rpow_def, *]
1578
1579 @[simp] lemma rpow_one (x : ℝ) : x ^ (1 : ℝ) = x := by simp [rpow_def]
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
doc └──┘
1580
1581 @[simp] lemma one_rpow (x : ℝ) : (1 : ℝ) ^ x = 1 := by simp [rpow_def]
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
doc └──┘
1582
1583 lemma rpow_nonneg_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : 0 ≤ x ^ y :=
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1584 by rw [rpow_def_of_nonneg hx];
1585 split_ifs; simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)]
1586
1587 lemma rpow_add {x : ℝ} (y z : ℝ) (hx : 0 < x) : x ^ (y + z) = x ^ y * x ^ z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1588 by simp only [rpow_def_of_pos hx, mul_add, exp_add]
1589
1590 lemma rpow_mul {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1591 by rw [← complex.of_real_inj, complex.of_real_cpow (rpow_nonneg_of_nonneg hx _),
1592 complex.of_real_cpow hx, complex.of_real_mul, complex.cpow_mul, complex.of_real_cpow hx];
1593 simp only [(complex.of_real_mul _ _).symm, (complex.of_real_log hx).symm,
1594 complex.of_real_im, neg_lt_zero, pi_pos, le_of_lt pi_pos]
1595
1596 lemma rpow_neg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ -y = (x ^ y)⁻¹ :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1597 by simp only [rpow_def_of_nonneg hx]; split_ifs; simp [*, exp_neg] at *
1598
1599 @[simp] lemma rpow_nat_cast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
1600 by simp only [rpow_def, (complex.of_real_pow _ _).symm, complex.cpow_nat_cast,
1601 complex.of_real_nat_cast, complex.of_real_re]
1602
1603 @[simp] lemma rpow_int_cast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
doc └──┘
1604 by simp only [rpow_def, (complex.of_real_fpow _ _).symm, complex.cpow_int_cast,
1605 complex.of_real_int_cast, complex.of_real_re]
1606
1607 lemma mul_rpow {x y z : ℝ} (h : 0 ≤ x) (h₁ : 0 ≤ y) : (x*y)^z = x^z * y^z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1608 begin
1609 iterate 3 { rw real.rpow_def_of_nonneg }, split_ifs; simp * at *,
1610 { have hx : 0 < x, cases lt_or_eq_of_le h with h₂ h₂, exact h₂, exfalso, apply h_2, exact eq.symm h₂,
id ┴
typ ┴
1611 have hy : 0 < y, cases lt_or_eq_of_le h₁ with h₂ h₂, exact h₂, exfalso, apply h_3, exact eq.symm h₂,
id ┴
typ ┴
1612 rw [log_mul hx hy, add_mul, exp_add]},
st └─┘
1613 { exact h₁},
st └┘
1614 { exact h},
st └┘
1615 { exact mul_nonneg h h₁},
st └┘
1616 end
st └─┘
1617
1618 lemma one_le_rpow {x z : ℝ} (h : 1 ≤ x) (h₁ : 0 ≤ z) : 1 ≤ x^z :=
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
1619 begin
1620 rw real.rpow_def_of_nonneg, split_ifs with h₂ h₃,
1621 { refl},
st └┘
1622 { simp [*, not_le_of_gt zero_lt_one] at *},
st └┘
1623 { have hx : 0 < x, exact lt_of_lt_of_le zero_lt_one h,
id ┴
typ ┴
1624 rw [←log_le_log zero_lt_one hx, log_one] at h,
1625 have pos : 0 ≤ log x * z, exact mul_nonneg h h₁,
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
doc └─┘
1626 rwa [←exp_le_exp, exp_zero] at pos},
st └┘
1627 { exact le_trans zero_le_one h},
st └┘
1628 end
st └─┘
1629
1630 lemma rpow_le_rpow {x y z: ℝ} (h : 0 ≤ x) (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x^z ≤ y^z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1631 begin
1632 rw le_iff_eq_or_lt at h h₂, cases h₂,
1633 { rw [←h₂, rpow_zero, rpow_zero]},
st └─┘
1634 { cases h,
1635 { rw [←h, zero_rpow], rw real.rpow_def_of_nonneg, split_ifs,
1636 { exact zero_le_one},
st └┘
1637 { refl},
st └┘
1638 { exact le_of_lt (exp_pos (log y * z))},
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
doc └─┘
st └┘
1639 { rwa ←h at h₁},
st └┘
1640 { exact ne.symm (ne_of_lt h₂)}},
st └─┘
1641 { have one_le : 1 ≤ y / x, rw one_le_div_iff_le h, exact h₁,
id ┴ ┴ └┘
typ ┴ ┴ └┘
1642 have one_le_pow : 1 ≤ (y / x)^z, exact one_le_rpow one_le (le_of_lt h₂),
id ┴ ┴ ┴
typ ┴ ┴ ┴
1643 rw [←mul_div_cancel y (ne.symm (ne_of_lt h)), mul_comm, mul_div_assoc],
id ┴
typ ┴
1644 rw [mul_rpow (le_of_lt h) (le_trans zero_le_one one_le), mul_comm],
1645 exact (le_mul_of_ge_one_left (rpow_nonneg_of_nonneg (le_of_lt h) z) one_le_pow) } }
id ┴
typ ┴
st └───
1646 end
st ──┘
1647
1648 lemma rpow_lt_rpow (hx : 0 ≤ x) (hxy : x < y) (hz : 0 < z) : x^z < y^z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1649 begin
1650 rw le_iff_eq_or_lt at hx, cases hx,
1651 { rw [← hx, zero_rpow (ne_of_gt hz)], exact rpow_pos_of_pos (by rwa ← hx at hxy) _ },
st └┘
1652 rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp],
id └─┘
typ └─┘
1653 exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz
id └─┘
typ └─┘
1654 end
st └─┘
1655
1656 lemma rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x^y < x^z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1657 begin
1658 repeat {rw [rpow_def_of_pos (lt_trans zero_lt_one hx)]},
1659 rw exp_lt_exp, exact mul_lt_mul_of_pos_left hyz (log_pos hx),
id └─┘
typ └─┘
1660 end
st └─┘
1661
1662 lemma rpow_le_rpow_of_exponent_le (hx : 1 ≤ x) (hyz : y ≤ z) : x^y ≤ x^z :=
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1663 begin
1664 repeat {rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)]},
1665 rw exp_le_exp, exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx),
id └─┘
typ └─┘
1666 end
st └─┘
1667
1668 lemma rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1669 x^y < x^z :=
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1670 begin
1671 repeat {rw [rpow_def_of_pos hx0]},
1672 rw exp_lt_exp, exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1),
id └─┘
typ └─┘
1673 end
st └─┘
1674
1675 lemma rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x ≤ 1) (hyz : z ≤ y) :
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1676 x^y ≤ x^z :=
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1677 begin
1678 repeat {rw [rpow_def_of_pos hx0]},
1679 rw exp_le_exp, exact mul_le_mul_of_nonpos_left hyz (log_nonpos hx1),
id └─┘
typ └─┘
1680 end
st └─┘
1681
1682 lemma rpow_le_one {x e : ℝ} (he : 0 ≤ e) (hx : 0 ≤ x) (hx2 : x ≤ 1) : x^e ≤ 1 :=
id ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴
1683 by rw ←one_rpow e; apply rpow_le_rpow; assumption
id └────────┘
src └────────┘
typ └────────┘
doc └────────┘
1684
1685 lemma one_lt_rpow (hx : 1 < x) (hz : 0 < z) : 1 < x^z :=
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1686 by { rw ← one_rpow z, exact rpow_lt_rpow zero_le_one hx hz }
st └┘
1687
1688 lemma rpow_lt_one (hx : 0 < x) (hx1 : x < 1) (hz : 0 < z) : x^z < 1 :=
id ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1689 by { rw ← one_rpow z, exact rpow_lt_rpow (le_of_lt hx) hx1 hz }
st └┘
1690
1691 lemma pow_nat_rpow_nat_inv {x : ℝ} (hx : 0 ≤ x) {n : ℕ} (hn : 0 < n) :
id ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴
1692 (x ^ n) ^ (n⁻¹ : ℝ) = x :=
id ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴
1693 have hn0 : (n : ℝ) ≠ 0, by simpa [nat.pos_iff_ne_zero] using hn,
id ┴
typ ┴
1694 by rw [← rpow_nat_cast, ← rpow_mul hx, mul_inv_cancel hn0, rpow_one]
st ┴
1695
1696 section prove_rpow_is_continuous
1697
1698 lemma continuous_rpow_aux1 : continuous (λp : {p:ℝ×ℝ // 0 < p.1}, p.val.1 ^ p.val.2) :=
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
1699 suffices h : continuous (λ p : {p:ℝ×ℝ // 0 < p.1 }, exp (log p.val.1 * p.val.2)),
id ┴ ┴ ┴ └┘ └┘
src ┴ ┴ └┘ └┘
typ ┴ ┴ ┴ └┘ └┘
doc └┘
1700 by { convert h, ext p, rw rpow_def_of_pos p.2 },
st └┘
1701 continuous_exp.comp $
1702 (show continuous ((λp:{p:ℝ//0 < p}, log (p.val)) ∘ (λp:{p:ℝ×ℝ//0<p.fst}, ⟨p.val.1, p.2⟩)), from
id ┴ ┴ └─┘ ┴ ┴ ┴
src ┴ └─┘ ┴ ┴
typ ┴ ┴ └─┘ ┴ ┴ ┴
doc └─┘
1703 continuous_log'.comp $ continuous_subtype_mk _ $ continuous_fst.comp continuous_subtype_val).mul
1704 (continuous_snd.comp $ continuous_subtype_val.comp continuous_id)
1705
1706 lemma continuous_rpow_aux2 : continuous (λ p : {p:ℝ×ℝ // p.1 < 0}, p.val.1 ^ p.val.2) :=
id ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴
1707 suffices h : continuous (λp:{p:ℝ×ℝ // p.1 < 0}, exp (log (-p.val.1) * p.val.2) * cos (p.val.2 * π)),
id ┴ ┴ ┴ └─┘ ┴ ┴ ┴
src ┴ ┴ ┴ └─┘ ┴ ┴ ┴
typ ┴ ┴ ┴ └─┘ ┴ ┴ ┴
doc └─┘ ┴
1708 by { convert h, ext p, rw [rpow_def_of_neg p.2] },
st ┴ └┘
1709 (continuous_exp.comp $
1710 (show continuous $ (λp:{p:ℝ//0<p},
id ┴ ┴
src ┴
typ ┴ ┴
1711 log (p.val))∘(λp:{p:ℝ×ℝ//p.1<0}, ⟨-p.val.1, neg_pos_of_neg p.2⟩),
id └─┘ ┴ ┴ ┴
src └─┘ ┴ ┴
typ └─┘ ┴ ┴ ┴
doc └─┘
1712 from continuous_log'.comp $ continuous_subtype_mk _ $ continuous_neg.comp $
1713 continuous_fst.comp continuous_subtype_val).mul
1714 (continuous_snd.comp $ continuous_subtype_val.comp continuous_id)).mul
1715 (continuous_cos.comp $
1716 (continuous_snd.comp $ continuous_subtype_val.comp continuous_id).mul continuous_const)
1717
1718 lemma continuous_at_rpow_of_ne_zero (hx : x ≠ 0) (y : ℝ) :
id ┴ ┴
src ┴
typ ┴ ┴
1719 continuous_at (λp:ℝ×ℝ, p.1^p.2) (x, y) :=
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1720 begin
1721 cases lt_trichotomy 0 x,
1722 exact continuous_within_at.continuous_at
1723 (continuous_on_iff_continuous_restrict.2 continuous_rpow_aux1 _ h)
1724 (mem_nhds_sets (by { convert is_open_prod (is_open_lt' (0:ℝ)) is_open_univ, ext, finish }) h),
st └┘
1725 cases h,
1726 { exact absurd h.symm hx },
st └┘
1727 exact continuous_within_at.continuous_at
1728 (continuous_on_iff_continuous_restrict.2 continuous_rpow_aux2 _ h)
1729 (mem_nhds_sets (by { convert is_open_prod (is_open_gt' (0:ℝ)) is_open_univ, ext, finish }) h)
st └┘
1730 end
st └─┘
1731
1732 lemma continuous_rpow_aux3 : continuous (λ p : {p:ℝ×ℝ // 0 < p.2}, p.val.1 ^ p.val.2) :=
id ┴ ┴
src ┴ ┴
typ ┴ ┴
1733 continuous_iff_continuous_at.2 $ λ ⟨(x₀, y₀), hy₀⟩,
1734 begin
1735 by_cases hx₀ : x₀ = 0,
id └┘
typ └┘
1736 { simp only [continuous_at, hx₀, zero_rpow (ne_of_gt hy₀), tendsto_nhds_nhds], assume ε ε0,
1737 rcases exists_pos_rat_lt (half_pos hy₀) with ⟨q, q_pos, q_lt⟩,
1738 let q := (q:ℝ), replace q_pos : 0 < q := rat.cast_pos.2 q_pos,
id ┴ ┴
typ ┴ ┴
1739 let δ := min (min q (ε ^ (1 / q))) (1/2),
id ┴ ┴
typ ┴ ┴
1740 have δ0 : 0 < δ := lt_min (lt_min q_pos (rpow_pos_of_pos ε0 _)) (by norm_num),
id ┴
typ ┴
1741 have : δ ≤ q := le_trans (min_le_left _ _) (min_le_left _ _),
id ┴ ┴
typ ┴ ┴
1742 have : δ ≤ ε ^ (1 / q) := le_trans (min_le_left _ _) (min_le_right _ _),
id ┴ ┴ ┴
typ ┴ ┴ ┴
1743 have : δ < 1 := lt_of_le_of_lt (min_le_right _ _) (by norm_num),
id ┴
typ ┴
1744 use δ, use δ0, rintros ⟨⟨x, y⟩, hy⟩,
id ┴
typ ┴
1745 simp only [subtype.dist_eq, real.dist_eq, prod.dist_eq, sub_zero],
1746 assume h, rw max_lt_iff at h, cases h with xδ yy₀,
1747 have qy : q < y, calc q < y₀ / 2 : q_lt
id ┴ ┴ ┴ └┘
typ ┴ ┴ ┴ └┘
1748 ... = y₀ - y₀ / 2 : (sub_half _).symm
1749 ... ≤ y₀ - δ : by linarith
id ┴
typ ┴
1750 ... < y : sub_lt_of_abs_sub_lt_left yy₀,
id ┴
typ ┴
1751 calc abs(x^y) ≤ abs(x)^y : abs_rpow_le_abs_rpow _ _
id ┴ ┴
typ ┴ ┴
1752 ... < δ ^ y : rpow_lt_rpow (abs_nonneg _) xδ hy
id ┴
typ ┴
1753 ... < δ ^ q : by { refine rpow_lt_rpow_of_exponent_gt _ _ _, repeat {linarith} }
id ┴
typ ┴
st └──┘
1754 ... ≤ (ε ^ (1 / q)) ^ q : by { refine rpow_le_rpow _ _ _, repeat {linarith} }
st └──┘
1755 ... = ε : by { rw [← rpow_mul, div_mul_cancel, rpow_one], exact ne_of_gt q_pos, linarith }},
id ┴
typ ┴
st └─┘
1756 { exact (continuous_within_at_iff_continuous_at_restrict (λp:ℝ×ℝ, p.1^p.2) _).1
1757 (continuous_at_rpow_of_ne_zero hx₀ _).continuous_within_at }
st └─
1758 end
st ──┘
1759
1760 lemma continuous_at_rpow_of_pos (hy : 0 < y) (x : ℝ) :
id ┴ ┴
src ┴
typ ┴ ┴
1761 continuous_at (λp:ℝ×ℝ, p.1^p.2) (x, y) :=
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1762 continuous_within_at.continuous_at
1763 (continuous_on_iff_continuous_restrict.2 continuous_rpow_aux3 _ hy)
1764 (mem_nhds_sets (by { convert is_open_prod is_open_univ (is_open_lt' (0:ℝ)), ext, finish }) hy)
st └┘
1765
1766 variables {α : Type*} [topological_space α] {f g : α → ℝ}
id └┘ └──┘ └──┘ ┴ ┴
src └┘ └──┘ └──┘ ┴ ┴
typ └┘ └──┘ └──┘ ┴ ┴
doc └┘ └──┘ └──┘ ┴
1767
1768 /--
1769 `real.rpow` is continuous at all points except for the lower half of the y-axis.
1770 In other words, the function `λp:ℝ×ℝ, p.1^p.2` is continuous at `(x, y)` if `x ≠ 0` or `y > 0`.
1771
1772 Multiple forms of the claim is provided in the current section.
1773 -/
1774 lemma continuous_rpow (h : ∀a, f a ≠ 0 ∨ 0 < g a) (hf : continuous f) (hg : continuous g):
id ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
src ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1775 continuous (λa:α, (f a) ^ (g a)) :=
id ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴
1776 continuous_iff_continuous_at.2 $ λ a,
id ┴
typ ┴
1777 begin
1778 show continuous_at ((λp:ℝ×ℝ, p.1^p.2) ∘ (λa, (f a, g a))) a,
1779 refine continuous_at.comp _ (continuous_iff_continuous_at.1 (hf.prod_mk hg) _),
1780 { replace h := h a, cases h,
id ┴
typ ┴
1781 { exact continuous_at_rpow_of_ne_zero h _ },
st └┘
1782 { exact continuous_at_rpow_of_pos h _ }},
st └─┘
1783 end
st └─┘
1784
1785 lemma continuous_rpow_of_ne_zero (h : ∀a, f a ≠ 0) (hf : continuous f) (hg : continuous g):
id ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1786 continuous (λa:α, (f a) ^ (g a)) := continuous_rpow (λa, or.inl $ h a) hf hg
id ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴
1787
1788 lemma continuous_rpow_of_pos (h : ∀a, 0 < g a) (hf : continuous f) (hg : continuous g):
id ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1789 continuous (λa:α, (f a) ^ (g a)) := continuous_rpow (λa, or.inr $ h a) hf hg
id ┴ ┴ ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴ ┴ ┴
1790
1791 end prove_rpow_is_continuous
1792
1793 section sqrt
1794
1795 lemma sqrt_eq_rpow : sqrt = λx:ℝ, x ^ (1/(2:ℝ)) :=
id └┘ ┴ ┴ ┴
src └┘ ┴ ┴
typ └┘ ┴ ┴ ┴
1796 begin
1797 funext, by_cases h : 0 ≤ x,
id ┴
typ ┴
1798 { rw [← mul_self_inj_of_nonneg, mul_self_sqrt h, ← pow_two, ← rpow_nat_cast, ← rpow_mul h],
1799 norm_num, exact sqrt_nonneg _, exact rpow_nonneg_of_nonneg h _ },
st └┘
1800 { replace h : x < 0 := lt_of_not_ge h,
id ┴
typ ┴
1801 have : 1 / (2:ℝ) * π = π / (2:ℝ), ring,
1802 rw [sqrt_eq_zero_of_nonpos (le_of_lt h), rpow_def_of_neg h, this, cos_pi_div_two, mul_zero] }
st ┴ └─
1803 end
st ──┘
1804
1805 lemma continuous_sqrt : continuous sqrt :=
id └┘
src └┘
typ └┘
1806 by rw sqrt_eq_rpow; exact continuous_rpow_of_pos (λa, by norm_num) continuous_id continuous_const
id ┴
typ ┴
1807
1808 end sqrt
1809
1810 section exp
1811
1812 /-- The real exponential function tends to +infinity at +infinity -/
1813 lemma tendsto_exp_at_top : tendsto exp at_top at_top :=
id └┘
src └┘
typ └┘
1814 begin
1815 have A : tendsto (λx:ℝ, x + 1) at_top at_top :=
1816 tendsto_at_top_add_const_right at_top 1 tendsto_id,
1817 have B : ∀ᶠ x in at_top, x + 1 ≤ exp x,
id ┴ └─┘
src └─┘
typ ┴ └─┘
1818 { have : ∀ᶠ (x : ℝ) in at_top, 0 ≤ x := mem_at_top 0,
1819 filter_upwards [this],
1820 exact λx hx, add_one_le_exp_of_nonneg hx },
id ┴
typ ┴
st └┘
1821 exact tendsto_at_top_mono' at_top B A
1822 end
st └─┘
1823
1824 /-- The real exponential function tends to 0 at -infinity or, equivalently, `exp(-x)` tends to `0`
1825 at +infinity -/
1826 lemma tendsto_exp_neg_at_top_nhds_0 : tendsto (λx, exp (-x)) at_top (𝓝 0) :=
id ┴ └┘ ┴
src └┘
typ ┴ └┘ ┴
1827 (tendsto_inv_at_top_zero.comp (tendsto_exp_at_top)).congr (λx, (exp_neg x).symm)
id ┴ ┴
typ ┴ ┴
1828
1829 /-- The function `exp(x)/x^n` tends to +infinity at +infinity, for any natural number `n` -/
1830 lemma tendsto_exp_div_pow_at_top (n : ℕ) : tendsto (λx, exp x / x^n) at_top at_top :=
id ┴ ┴ └┘ ┴ ┴
src ┴ └┘
typ ┴ ┴ └┘ ┴ ┴
1831 begin
1832 have n_pos : (0 : ℝ) < n + 1 := nat.cast_add_one_pos n,
id ┴ ┴
typ ┴ ┴
1833 have n_ne_zero : (n : ℝ) + 1 ≠ 0 := ne_of_gt n_pos,
id ┴
typ ┴
1834 have A : ∀x:ℝ, 0 < x → exp (x / (n+1)) / (n+1)^n ≤ exp x / x^n,
id └─┘ ┴
src └─┘
typ └─┘ ┴
1835 { assume x hx,
1836 let y := x / (n+1),
id ┴ ┴
typ ┴ ┴
1837 have y_pos : 0 < y := div_pos hx n_pos,
id ┴
typ ┴
1838 have : exp (x / (n+1)) ≤ (n+1)^n * (exp x / x^n), from calc
id └─┘ ┴ ┴
src └─┘
typ └─┘ ┴ ┴
1839 exp y = exp y * 1 : by simp
id ┴
typ ┴
1840 ... ≤ exp y * (exp y / y)^n : begin
id ┴
typ ┴
1841 apply mul_le_mul_of_nonneg_left (one_le_pow_of_one_le _ n) (le_of_lt (exp_pos _)),
id ┴
typ ┴
1842 apply one_le_div_of_le _ y_pos,
1843 apply le_trans _ (add_one_le_exp_of_nonneg (le_of_lt y_pos)),
1844 exact le_add_of_le_of_nonneg (le_refl _) (zero_le_one)
1845 end
st └─┘
1846 ... = exp y * exp (n * y) / y^n :
1847 by rw [div_pow _ (ne_of_gt y_pos), exp_nat_mul, mul_div_assoc]
st ┴
1848 ... = exp ((n + 1) * y) / y^n :
1849 by rw [← exp_add, add_mul, one_mul, add_comm]
st ┴
1850 ... = exp x / (x / (n+1))^n :
1851 by { dsimp [y], rw mul_div_cancel' _ n_ne_zero }
id ┴
typ ┴
st └┘
1852 ... = (n+1)^n * (exp x / x^n) :
id ┴
typ ┴
1853 by rw [← mul_div_assoc, div_pow _ n_ne_zero, div_div_eq_mul_div, mul_comm],
st ┴
1854 rwa div_le_iff' (pow_pos n_pos n) },
id ┴
typ ┴
st └┘
1855 have B : ∀ᶠ x in at_top, exp (x / (n+1)) / (n+1)^n ≤ exp x / x^n :=
id ┴ └─┘ ┴
src └─┘
typ ┴ └─┘ ┴
1856 mem_at_top_sets.2 ⟨1, λx hx, A _ (lt_of_lt_of_le zero_lt_one hx)⟩,
id ┴
typ ┴
1857 have C : tendsto (λx, exp (x / (n+1)) / (n+1)^n) at_top at_top :=
id ┴ └─┘ ┴
src └─┘
typ ┴ └─┘ ┴
1858 tendsto_at_top_div (pow_pos n_pos n)
1859 (tendsto_exp_at_top.comp (tendsto_at_top_div (nat.cast_add_one_pos n) tendsto_id)),
id ┴
typ ┴
1860 exact tendsto_at_top_mono' at_top B C
1861 end
st └─┘
1862
1863 /-- The function `x^n * exp(-x)` tends to `0` at +infinity, for any natural number `n`. -/
1864 lemma tendsto_pow_mul_exp_neg_at_top_nhds_0 (n : ℕ) : tendsto (λx, x^n * exp (-x)) at_top (𝓝 0) :=
id ┴ ┴ ┴ ┴ └┘ ┴
src ┴ └┘
typ ┴ ┴ ┴ ┴ └┘ ┴
1865 (tendsto_inv_at_top_zero.comp (tendsto_exp_div_pow_at_top n)).congr $ λx,
id ┴ ┴
typ ┴ ┴
1866 by rw [function.comp_app, inv_eq_one_div, div_div_eq_mul_div, one_mul, div_eq_mul_inv, exp_neg]
st ┴
1867
1868 end exp
1869
1870 end real
1871
1872 lemma has_deriv_at.rexp {f : ℝ → ℝ} {f' x : ℝ} (hf : has_deriv_at f f' x) :
id ┴ ┴ ┴ ┴ └┘ ┴
src ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ └┘ ┴
1873 has_deriv_at (real.exp ∘ f) (f' * real.exp (f x)) x :=
id └┘ └┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴
src └┘ └┘ ┴ └┘ ┴
typ └┘ └┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴
1874 (real.has_deriv_at_exp (f x)).comp x hf
id ┴ ┴ ┴
typ ┴ ┴ ┴
1875
1876 lemma has_deriv_within_at.rexp {f : ℝ → ℝ} {f' x : ℝ} {s : set ℝ}
id ┴ ┴ ┴ ┴ ┴
src ┴ ┴ ┴ ┴ ┴
typ ┴ ┴ ┴ ┴ ┴
1877 (hf : has_deriv_within_at f f' s x) :
id ┴ └┘ ┴ ┴
typ ┴ └┘ ┴ ┴
1878 has_deriv_within_at (real.exp ∘ f) (f' * real.exp (f x)) s x :=
id └┘ └┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴
src └┘ └┘ ┴ └┘ ┴
typ └┘ └┘ ┴ └┘ ┴ └┘ ┴ ┴ ┴ ┴ ┴
1879 (real.has_deriv_at_exp (f x)).comp_has_deriv_within_at x hf
id ┴ ┴ ┴
typ ┴ ┴ ┴